Skip to content

Commit

Permalink
do not ignore mouse scrolling when on top of virtual text
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalkuthe authored and Schuyler Mortimer committed Jul 10, 2024
1 parent 14b8480 commit 384760a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,10 +1038,15 @@ impl EditorView {
..
} = *event;

let pos_and_view = |editor: &Editor, row, column| {
let pos_and_view = |editor: &Editor, row, column, ignore_virtual_text| {
editor.tree.views().find_map(|(view, _focus)| {
view.pos_at_screen_coords(&editor.documents[&view.doc], row, column, true)
.map(|pos| (pos, view.id))
view.pos_at_screen_coords(
&editor.documents[&view.doc],
row,
column,
ignore_virtual_text,
)
.map(|pos| (pos, view.id))
})
};

Expand All @@ -1056,7 +1061,7 @@ impl EditorView {
MouseEventKind::Down(MouseButton::Left) => {
let editor = &mut cxt.editor;

if let Some((pos, view_id)) = pos_and_view(editor, row, column) {
if let Some((pos, view_id)) = pos_and_view(editor, row, column, true) {
let doc = doc_mut!(editor, &view!(editor, view_id).doc);

if modifiers == KeyModifiers::ALT {
Expand Down Expand Up @@ -1120,7 +1125,7 @@ impl EditorView {
_ => unreachable!(),
};

match pos_and_view(cxt.editor, row, column) {
match pos_and_view(cxt.editor, row, column, false) {
Some((_, view_id)) => cxt.editor.tree.focus = view_id,
None => return EventResult::Ignored(None),
}
Expand Down Expand Up @@ -1191,7 +1196,7 @@ impl EditorView {
return EventResult::Consumed(None);
}

if let Some((pos, view_id)) = pos_and_view(editor, row, column) {
if let Some((pos, view_id)) = pos_and_view(editor, row, column, true) {
let doc = doc_mut!(editor, &view!(editor, view_id).doc);
doc.set_selection(view_id, Selection::point(pos));
cxt.editor.focus(view_id);
Expand Down

0 comments on commit 384760a

Please sign in to comment.