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

Use the current document and view for mode-change hooks #3508

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
7 changes: 5 additions & 2 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,8 @@ impl Component for EditorView {
// clear status
cx.editor.status_msg = None;

let doc = doc!(cx.editor);
let (view, doc) = current!(cx.editor);
let focus = view.id;
let mode = doc.mode();

if let Some(on_next_key) = self.on_next_key.take() {
Expand Down Expand Up @@ -1204,7 +1205,9 @@ impl Component for EditorView {
return EventResult::Ignored(None);
}
let config = cx.editor.config();
let (view, doc) = current!(cx.editor);
let view = cx.editor.tree.get_mut(focus);
let doc = cx.editor.documents.get_mut(&view.doc).unwrap();

view.ensure_cursor_in_view(doc, config.scrolloff);

// Store a history state if not in insert mode. This also takes care of
Expand Down