aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorMichael Davis2022-08-31 01:34:04 +0000
committerGitHub2022-08-31 01:34:04 +0000
commit9e24f2aa81f6bbb1fecbf6c7a14a56742389444f (patch)
treee31b68b6d60d4756fb1121f7d0096a3d7b6cc0c6 /helix-term/src
parent16525349dbb2b72064e1cfb5cc3164dc236fd367 (diff)
Use the original document and view for mode transition hooks (#3508)
When changing focus, the lookup with `current!` may change the view and end up executing mode transition hooks on the newly focused view. We should use the same view and document to execute mode transition hooks so that switching away from a view triggers history save points.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/ui/editor.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 7326b70d..92773260 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -1157,7 +1157,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() {
@@ -1221,7 +1222,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