Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up completion, signatureHelp, and hover popup after mouse action #5341

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,31 @@ impl EditorView {
}

impl EditorView {
fn clean_up(&mut self, cxt: &mut commands::Context) {
// not sure if this two should be clean up
// cxt.editor.reset_idle_timer();
// cxt.editor.status_msg = None;

// clean up completion
self.completion = None;

// clean up signatureHelp
cxt.jobs.callback(async {
let call: job::Callback =
Callback::EditorCompositor(Box::new(|_editor, compositor| {
compositor.remove(SignatureHelp::ID);
}));
Ok(call)
});
// clean up hover popup
cxt.jobs.callback(async {
let call: job::Callback =
Callback::EditorCompositor(Box::new(|_editor, compositor| {
compositor.remove("hover");
}));
Ok(call)
});
}
fn handle_mouse_event(
&mut self,
event: &MouseEvent,
Expand Down Expand Up @@ -1142,6 +1167,8 @@ impl EditorView {

match kind {
MouseEventKind::Down(MouseButton::Left) => {
self.clean_up(cxt);

let editor = &mut cxt.editor;

if let Some((pos, view_id)) = pos_and_view(editor, row, column) {
Expand Down Expand Up @@ -1181,6 +1208,8 @@ impl EditorView {
}

MouseEventKind::Drag(MouseButton::Left) => {
self.clean_up(cxt);

let (view, doc) = current!(cxt.editor);

let pos = match view.pos_at_screen_coords(doc, row, column) {
Expand All @@ -1198,6 +1227,8 @@ impl EditorView {
}

MouseEventKind::ScrollUp | MouseEventKind::ScrollDown => {
self.clean_up(cxt);

let current_view = cxt.editor.tree.focus;

let direction = match event.kind {
Expand All @@ -1221,6 +1252,8 @@ impl EditorView {
}

MouseEventKind::Up(MouseButton::Left) => {
self.clean_up(cxt);

if !config.middle_click_paste {
return EventResult::Ignored(None);
}
Expand All @@ -1243,6 +1276,8 @@ impl EditorView {
}

MouseEventKind::Up(MouseButton::Right) => {
self.clean_up(cxt);

if let Some((coords, view_id)) = gutter_coords_and_view(cxt.editor, row, column) {
cxt.editor.focus(view_id);

Expand All @@ -1264,6 +1299,8 @@ impl EditorView {
}

MouseEventKind::Up(MouseButton::Middle) => {
self.clean_up(cxt);

let editor = &mut cxt.editor;
if !config.middle_click_paste {
return EventResult::Ignored(None);
Expand Down