From 673caeea9fbbed03a801acdbc506e51057b2653b Mon Sep 17 00:00:00 2001 From: Diego Date: Mon, 8 Apr 2024 17:20:53 +0200 Subject: [PATCH] fix mouse right click selection (#10067) --- helix-term/src/ui/editor.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 97a08beb75f8..dc767e22eea8 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1263,24 +1263,28 @@ impl EditorView { } MouseEventKind::Up(MouseButton::Right) => { - if let Some((coords, view_id)) = gutter_coords_and_view(cxt.editor, row, column) { + if let Some((pos, view_id)) = gutter_coords_and_view(cxt.editor, row, column) { cxt.editor.focus(view_id); - let (view, doc) = current!(cxt.editor); - if let Some(pos) = - view.pos_at_visual_coords(doc, coords.row as u16, coords.col as u16, true) - { - doc.set_selection(view_id, Selection::point(pos)); - if modifiers == KeyModifiers::ALT { - commands::MappableCommand::dap_edit_log.execute(cxt); - } else { - commands::MappableCommand::dap_edit_condition.execute(cxt); - } + if let Some((pos, _)) = pos_and_view(cxt.editor, row, column, true) { + doc_mut!(cxt.editor).set_selection(view_id, Selection::point(pos)); + } else { + let (view, doc) = current!(cxt.editor); - return EventResult::Consumed(None); + if let Some(pos) = view.pos_at_visual_coords(doc, pos.row as u16, 0, true) { + doc.set_selection(view_id, Selection::point(pos)); + match modifiers { + KeyModifiers::ALT => { + commands::MappableCommand::dap_edit_log.execute(cxt) + } + _ => commands::MappableCommand::dap_edit_condition.execute(cxt), + }; + } } - } + cxt.editor.ensure_cursor_in_view(view_id); + return EventResult::Consumed(None); + } EventResult::Ignored(None) }