From 99b0a425a291a61ce08841894646c213ca6feb2b Mon Sep 17 00:00:00 2001 From: diegostafa Date: Sun, 31 Mar 2024 12:08:18 +0200 Subject: [PATCH 1/6] use document coordinates --- helix-term/src/ui/editor.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index ad7aa5c5a89a..7fda12d9070b 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1231,22 +1231,19 @@ 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)) = pos_and_view(cxt.editor, row, column, true) { 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); - } + let doc = current!(cxt.editor).1; + doc.set_selection(view_id, Selection::point(pos)); - return EventResult::Consumed(None); + if modifiers == KeyModifiers::ALT { + commands::MappableCommand::dap_edit_log.execute(cxt); + } else { + commands::MappableCommand::dap_edit_condition.execute(cxt); } + + return EventResult::Consumed(None); } EventResult::Ignored(None) From 89fa9576ccce3a534f757116a629bb430b2ab03e Mon Sep 17 00:00:00 2001 From: Diego Date: Sun, 31 Mar 2024 17:30:27 +0200 Subject: [PATCH 2/6] use doc_mut! instead of current! Co-authored-by: Michael Davis --- helix-term/src/ui/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 7fda12d9070b..ceaf467c2f7d 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1234,7 +1234,7 @@ impl EditorView { if let Some((pos, view_id)) = pos_and_view(cxt.editor, row, column, true) { cxt.editor.focus(view_id); - let doc = current!(cxt.editor).1; + let doc = doc_mut!(cxt.editor); doc.set_selection(view_id, Selection::point(pos)); if modifiers == KeyModifiers::ALT { From bfe3cda8d2f7cd19ca71f978a80a27177ed69cb3 Mon Sep 17 00:00:00 2001 From: diegostafa Date: Mon, 1 Apr 2024 07:16:15 +0200 Subject: [PATCH 3/6] add ensure_cursor_in_view at the end --- helix-term/src/ui/editor.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index ceaf467c2f7d..f89fcfd1c32e 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1243,6 +1243,7 @@ impl EditorView { commands::MappableCommand::dap_edit_condition.execute(cxt); } + cxt.editor.ensure_cursor_in_view(current_view); return EventResult::Consumed(None); } From aa4aba32d1d6594f45bae0d8f35d32bbfe7bb137 Mon Sep 17 00:00:00 2001 From: diegostafa Date: Mon, 1 Apr 2024 07:21:03 +0200 Subject: [PATCH 4/6] wrong view name --- helix-term/src/ui/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index f89fcfd1c32e..c988f3ce95a6 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1243,7 +1243,7 @@ impl EditorView { commands::MappableCommand::dap_edit_condition.execute(cxt); } - cxt.editor.ensure_cursor_in_view(current_view); + cxt.editor.ensure_cursor_in_view(view_id); return EventResult::Consumed(None); } From 7f9dcf1dc694cde6bc9852464caf3b63e0b2e4d9 Mon Sep 17 00:00:00 2001 From: diegostafa Date: Mon, 1 Apr 2024 18:43:27 +0200 Subject: [PATCH 5/6] handle dap edits in margins --- helix-term/src/ui/editor.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index c988f3ce95a6..5be7ae07c12b 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1233,17 +1233,20 @@ impl EditorView { MouseEventKind::Up(MouseButton::Right) => { if let Some((pos, view_id)) = pos_and_view(cxt.editor, row, column, true) { cxt.editor.focus(view_id); + doc_mut!(cxt.editor).set_selection(view_id, Selection::point(pos)); + cxt.editor.ensure_cursor_in_view(view_id); - let doc = doc_mut!(cxt.editor); - doc.set_selection(view_id, Selection::point(pos)); + return EventResult::Consumed(None); + } - if modifiers == KeyModifiers::ALT { - commands::MappableCommand::dap_edit_log.execute(cxt); - } else { - commands::MappableCommand::dap_edit_condition.execute(cxt); - } + if let Some((_, view_id)) = gutter_coords_and_view(cxt.editor, row, column) { + cxt.editor.focus(view_id); + + 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); } From cee5a88a106f1bf718a04d25d92a48a744638beb Mon Sep 17 00:00:00 2001 From: diegostafa Date: Mon, 1 Apr 2024 19:19:57 +0200 Subject: [PATCH 6/6] move selection on breakpoint line --- helix-term/src/ui/editor.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 5be7ae07c12b..efa60676a075 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1231,25 +1231,28 @@ impl EditorView { } MouseEventKind::Up(MouseButton::Right) => { - if let Some((pos, view_id)) = pos_and_view(cxt.editor, row, column, true) { + if let Some((pos, view_id)) = gutter_coords_and_view(cxt.editor, row, column) { cxt.editor.focus(view_id); - doc_mut!(cxt.editor).set_selection(view_id, Selection::point(pos)); - cxt.editor.ensure_cursor_in_view(view_id); - - return EventResult::Consumed(None); - } - if let Some((_, view_id)) = gutter_coords_and_view(cxt.editor, row, column) { - cxt.editor.focus(view_id); + 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); - match modifiers { - KeyModifiers::ALT => commands::MappableCommand::dap_edit_log.execute(cxt), - _ => commands::MappableCommand::dap_edit_condition.execute(cxt), - }; + 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) }