aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs59
1 files changed, 9 insertions, 50 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 9f186d14..fef62a29 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -1,7 +1,6 @@
use crate::{
commands::{self, OnKeyCallback},
compositor::{Component, Context, Event, EventResult},
- job::{self, Callback},
events::{OnModeSwitch, PostCommand},
key,
keymap::{KeymapResult, Keymaps},
@@ -34,8 +33,8 @@ use std::{mem::take, num::NonZeroUsize, path::PathBuf, rc::Rc, sync::Arc};
use tui::{buffer::Buffer as Surface, text::Span};
+use super::document::LineDecoration;
use super::{completion::CompletionItem, statusline};
-use super::{document::LineDecoration, lsp::SignatureHelp};
pub struct EditorView {
pub keymaps: Keymaps,
@@ -837,11 +836,8 @@ impl EditorView {
let mut execute_command = |command: &commands::MappableCommand| {
command.execute(cxt);
helix_event::dispatch(PostCommand { command, cx: cxt });
+
let current_mode = cxt.editor.mode();
- match (last_mode, current_mode) {
- (Mode::Normal, Mode::Insert) => {
- // HAXX: if we just entered insert mode from normal, clear key buf
- // and record the command that got us into this mode.
if current_mode != last_mode {
helix_event::dispatch(OnModeSwitch {
old_mode: last_mode,
@@ -849,29 +845,16 @@ impl EditorView {
cx: cxt,
});
+ // HAXX: if we just entered insert mode from normal, clear key buf
+ // and record the command that got us into this mode.
+ if current_mode == Mode::Insert {
// how we entered insert mode is important, and we should track that so
// we can repeat the side effect.
self.last_insert.0 = command.clone();
self.last_insert.1.clear();
-
- commands::signature_help_impl(cxt, commands::SignatureHelpInvoked::Automatic);
- }
- (Mode::Insert, Mode::Normal) => {
- // if exiting insert mode, remove completion
- self.clear_completion(cxt.editor);
- cxt.editor.completion_request_handle = None;
-
- // TODO: Use an on_mode_change hook to remove signature help
- cxt.jobs.callback(async {
- let call: job::Callback =
- Callback::EditorCompositor(Box::new(|_editor, compositor| {
- compositor.remove(SignatureHelp::ID);
- }));
- Ok(call)
- });
}
- _ => (),
}
+
last_mode = current_mode;
};
@@ -999,12 +982,10 @@ impl EditorView {
editor: &mut Editor,
savepoint: Arc<SavePoint>,
items: Vec<CompletionItem>,
- start_offset: usize,
trigger_offset: usize,
size: Rect,
) -> Option<Rect> {
- let mut completion =
- Completion::new(editor, savepoint, items, start_offset, trigger_offset);
+ let mut completion = Completion::new(editor, savepoint, items, trigger_offset);
if completion.is_empty() {
// skip if we got no completion results
@@ -1025,6 +1006,7 @@ impl EditorView {
self.completion = None;
if let Some(last_completion) = editor.last_completion.take() {
match last_completion {
+ CompleteAction::Triggered => (),
CompleteAction::Applied {
trigger_offset,
changes,
@@ -1038,9 +1020,6 @@ impl EditorView {
}
}
}
-
- // Clear any savepoints
- editor.clear_idle_timer(); // don't retrigger
}
pub fn handle_idle_timeout(&mut self, cx: &mut commands::Context) -> EventResult {
@@ -1054,13 +1033,7 @@ impl EditorView {
};
}
- if cx.editor.mode != Mode::Insert || !cx.editor.config().auto_completion {
- return EventResult::Ignored(None);
- }
-
- crate::commands::insert::idle_completion(cx);
-
- EventResult::Consumed(None)
+ EventResult::Ignored(None)
}
}
@@ -1346,12 +1319,6 @@ impl Component for EditorView {
if callback.is_some() {
// assume close_fn
self.clear_completion(cx.editor);
-
- // In case the popup was deleted because of an intersection w/ the auto-complete menu.
- commands::signature_help_impl(
- &mut cx,
- commands::SignatureHelpInvoked::Automatic,
- );
}
}
}
@@ -1362,14 +1329,6 @@ impl Component for EditorView {
// record last_insert key
self.last_insert.1.push(InsertEvent::Key(key));
-
- // lastly we recalculate completion
- if let Some(completion) = &mut self.completion {
- completion.update(&mut cx);
- if completion.is_empty() {
- self.clear_completion(cx.editor);
- }
- }
}
}
mode => self.command_mode(mode, &mut cx, key),