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

mouse operations respect scrolloff #5255

Merged
Merged
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
5 changes: 4 additions & 1 deletion helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ impl EditorView {
}

editor.focus(view_id);
editor.ensure_cursor_in_view(view_id);

return EventResult::Consumed(None);
}
Expand Down Expand Up @@ -1191,7 +1192,8 @@ impl EditorView {
let primary = selection.primary_mut();
*primary = primary.put_cursor(doc.text().slice(..), pos, true);
doc.set_selection(view.id, selection);

let view_id = view.id;
cxt.editor.ensure_cursor_in_view(view_id);
EventResult::Consumed(None)
}

Expand All @@ -1213,6 +1215,7 @@ impl EditorView {
commands::scroll(cxt, offset, direction);

cxt.editor.tree.focus = current_view;
cxt.editor.ensure_cursor_in_view(current_view);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? commands::scroll already respects scrolloff

Copy link
Contributor Author

@hunterliao29 hunterliao29 Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the commands::scroll does respects scrolloff. However, if the file like this:

----------------------------| visible at this point--------------| cursor here
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglong[]onglonglonglong
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
short or empty
short or empty
short or empty
short or empty
short or empty

after scroll down

--------------| cursor here | still visible at this point
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglong[]onglonglonglong
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
short or empty
short or empty
short or empt[]
short or empty
short or empty

the cursor will not be visible and not respects scrolloff.


EventResult::Consumed(None)
}
Expand Down