VERY SUSPICIOUS BREAKING FUNCTIONALITY CHECK LATER
This commit is contained in:
@@ -19,6 +19,11 @@ pub async fn handle_edit_event_internal(
|
||||
total_count: u64,
|
||||
grpc_client: &mut GrpcClient,
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
if let Some("enter_command_mode") = config.get_action_for_key_in_mode(&config.keybindings.global, key.code, key.modifiers) {
|
||||
// Ignore in edit mode and process as normal input
|
||||
handle_edit_specific_input(key, form_state, ideal_cursor_column);
|
||||
return Ok(command_message.clone());
|
||||
}
|
||||
if let Some(action) = config.get_edit_action_for_key(key.code, key.modifiers) {
|
||||
return execute_edit_action(
|
||||
action,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// src/modes/handlers/event.rs
|
||||
use crossterm::event::{Event, KeyCode};
|
||||
use crossterm::event::Event;
|
||||
use crossterm::cursor::SetCursorStyle;
|
||||
use crate::tui::terminal::{
|
||||
core::TerminalCore,
|
||||
@@ -81,6 +81,42 @@ impl EventHandler {
|
||||
)));
|
||||
}
|
||||
|
||||
// Handle edit mode first to allow normal character input
|
||||
if self.is_edit_mode {
|
||||
if config.is_exit_edit_mode(key_code, modifiers) {
|
||||
if form_state.has_unsaved_changes {
|
||||
self.command_message = "Unsaved changes! Use :w to save or :q! to discard".to_string();
|
||||
return Ok((false, self.command_message.clone()));
|
||||
}
|
||||
self.is_edit_mode = false;
|
||||
self.edit_mode_cooldown = true;
|
||||
self.command_message = "Read-only mode".to_string();
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?;
|
||||
|
||||
let current_input = form_state.get_current_input();
|
||||
if !current_input.is_empty() && form_state.current_cursor_pos >= current_input.len() {
|
||||
form_state.current_cursor_pos = current_input.len() - 1;
|
||||
self.ideal_cursor_column = form_state.current_cursor_pos;
|
||||
}
|
||||
return Ok((false, self.command_message.clone()));
|
||||
}
|
||||
|
||||
let result = edit::handle_edit_event_internal(
|
||||
key,
|
||||
config,
|
||||
form_state,
|
||||
&mut self.ideal_cursor_column,
|
||||
&mut self.command_message,
|
||||
&mut app_state.ui.is_saved,
|
||||
current_position,
|
||||
total_count,
|
||||
grpc_client,
|
||||
).await?;
|
||||
|
||||
self.key_sequence_tracker.reset();
|
||||
return Ok((false, result));
|
||||
}
|
||||
|
||||
// Global command mode activation
|
||||
let context_action = config.get_action_for_current_context(
|
||||
self.is_edit_mode,
|
||||
@@ -92,7 +128,6 @@ impl EventHandler {
|
||||
);
|
||||
|
||||
if let Some("enter_command_mode") = context_action {
|
||||
if self.is_edit_mode { return Ok((false, String::new())); }
|
||||
self.command_mode = true;
|
||||
self.command_input.clear();
|
||||
self.command_message.clear();
|
||||
@@ -156,40 +191,6 @@ impl EventHandler {
|
||||
return Ok((should_exit, message));
|
||||
}
|
||||
|
||||
if self.is_edit_mode {
|
||||
if config.is_exit_edit_mode(key_code, modifiers) {
|
||||
if form_state.has_unsaved_changes {
|
||||
self.command_message = "Unsaved changes! Use :w to save or :q! to discard".to_string();
|
||||
return Ok((false, self.command_message.clone()));
|
||||
}
|
||||
self.is_edit_mode = false;
|
||||
self.edit_mode_cooldown = true;
|
||||
self.command_message = "Read-only mode".to_string();
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?;
|
||||
|
||||
let current_input = form_state.get_current_input();
|
||||
if !current_input.is_empty() && form_state.current_cursor_pos >= current_input.len() {
|
||||
form_state.current_cursor_pos = current_input.len() - 1;
|
||||
self.ideal_cursor_column = form_state.current_cursor_pos;
|
||||
}
|
||||
return Ok((false, self.command_message.clone()));
|
||||
}
|
||||
|
||||
let result = edit::handle_edit_event_internal(
|
||||
key,
|
||||
config,
|
||||
form_state,
|
||||
&mut self.ideal_cursor_column,
|
||||
&mut self.command_message,
|
||||
&mut app_state.ui.is_saved,
|
||||
current_position,
|
||||
total_count,
|
||||
grpc_client,
|
||||
).await?;
|
||||
|
||||
self.key_sequence_tracker.reset();
|
||||
return Ok((false, result));
|
||||
} else {
|
||||
if let Some(action) = config.get_read_only_action_for_key(key_code, modifiers) {
|
||||
if action == "enter_command_mode" {
|
||||
self.command_mode = true;
|
||||
@@ -233,7 +234,6 @@ impl EventHandler {
|
||||
&mut self.ideal_cursor_column,
|
||||
).await;
|
||||
}
|
||||
}
|
||||
|
||||
self.edit_mode_cooldown = false;
|
||||
Ok((false, self.command_message.clone()))
|
||||
|
||||
Reference in New Issue
Block a user