comments for reimplementation of autotrigger

This commit is contained in:
Priec
2025-08-11 23:08:57 +02:00
parent 189d3d2fc5
commit 8b742bbe09

View File

@@ -670,6 +670,7 @@ async fn handle_key_press(
(AppMode::ReadOnly, KeyCode::Char('i'), _) => { (AppMode::ReadOnly, KeyCode::Char('i'), _) => {
editor.enter_edit_mode(); editor.enter_edit_mode();
editor.clear_command_buffer(); editor.clear_command_buffer();
// For auto-suggestions on insert: add `editor.auto_trigger_suggestions(suggestions_provider).await;`
} }
(AppMode::ReadOnly, KeyCode::Char('a'), _) => { (AppMode::ReadOnly, KeyCode::Char('a'), _) => {
editor.enter_append_mode(); editor.enter_append_mode();
@@ -812,6 +813,7 @@ async fn handle_key_press(
(AppMode::Edit, KeyCode::Backspace, _) => { (AppMode::Edit, KeyCode::Backspace, _) => {
editor.delete_backward()?; editor.delete_backward()?;
// Auto-fetch only if suggestions are already active (triggered by Tab) // Auto-fetch only if suggestions are already active (triggered by Tab)
// For full auto-triggering: remove the `if` check below
if editor.is_suggestions_active() { if editor.is_suggestions_active() {
let field_index = editor.current_field(); let field_index = editor.current_field();
editor.trigger_suggestions_async(suggestions_provider, field_index).await; editor.trigger_suggestions_async(suggestions_provider, field_index).await;
@@ -820,6 +822,7 @@ async fn handle_key_press(
(AppMode::Edit, KeyCode::Delete, _) => { (AppMode::Edit, KeyCode::Delete, _) => {
editor.delete_forward()?; editor.delete_forward()?;
// Auto-fetch only if suggestions are already active (triggered by Tab) // Auto-fetch only if suggestions are already active (triggered by Tab)
// For full auto-triggering: remove the `if` check below
if editor.is_suggestions_active() { if editor.is_suggestions_active() {
let field_index = editor.current_field(); let field_index = editor.current_field();
editor.trigger_suggestions_async(suggestions_provider, field_index).await; editor.trigger_suggestions_async(suggestions_provider, field_index).await;
@@ -840,6 +843,7 @@ async fn handle_key_press(
(AppMode::Edit, KeyCode::Char(c), m) if !m.contains(KeyModifiers::CONTROL) => { (AppMode::Edit, KeyCode::Char(c), m) if !m.contains(KeyModifiers::CONTROL) => {
editor.insert_char(c)?; editor.insert_char(c)?;
// Auto-fetch only if suggestions are already active (triggered by Tab) // Auto-fetch only if suggestions are already active (triggered by Tab)
// For full auto-triggering: remove the `if` check below
if editor.is_suggestions_active() { if editor.is_suggestions_active() {
let field_index = editor.current_field(); let field_index = editor.current_field();
editor.trigger_suggestions_async(suggestions_provider, field_index).await; editor.trigger_suggestions_async(suggestions_provider, field_index).await;