From 15b387218a7d65210b1f2f363c7d789fb31e5232 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Tue, 21 Sep 2021 00:27:29 +0900 Subject: [PATCH] update completion when key is delete or left/right --- src/components/sql_editor.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/sql_editor.rs b/src/components/sql_editor.rs index b6050bb..63f2a72 100644 --- a/src/components/sql_editor.rs +++ b/src/components/sql_editor.rs @@ -51,7 +51,7 @@ impl SqlEditorComponent { input_idx: 0, input_cursor_position_x: 0, table: TableComponent::new(key_config.clone()), - completion: CompletionComponent::new(key_config.clone(), ""), + completion: CompletionComponent::new(key_config.clone(), "", true), focus: Focus::Editor, query_result: None, key_config, @@ -193,7 +193,7 @@ impl StatefulDrawableComponent for SqlEditorComponent { ) } - if focused { + if focused && matches!(self.focus, Focus::Editor) { self.completion.draw( f, area, @@ -234,6 +234,7 @@ impl Component for SqlEditorComponent { let last_c = self.input.remove(self.input_idx - 1); self.input_idx -= 1; self.input_cursor_position_x -= compute_character_width(last_c); + self.completion.update(""); } return Ok(EventState::Consumed); @@ -244,6 +245,7 @@ impl Component for SqlEditorComponent { self.input_cursor_position_x = self .input_cursor_position_x .saturating_sub(compute_character_width(self.input[self.input_idx])); + self.completion.update(""); } return Ok(EventState::Consumed); } @@ -252,6 +254,7 @@ impl Component for SqlEditorComponent { let next_c = self.input[self.input_idx]; self.input_idx += 1; self.input_cursor_position_x += compute_character_width(next_c); + self.completion.update(""); } return Ok(EventState::Consumed); }