on master help sign in
Use the original document and view for mode transition hooks (#3508)
9e24f2aMichael Davis
helix-term/src/ui/editor.rs+5−2
@@ -1157,7 +1157,8 @@ impl Component for EditorView {
1157 // clear status
1157 // clear status
1158 cx.editor.status_msg = None;
1158 cx.editor.status_msg = None;
1159
1159
1160− let doc = doc!(cx.editor);
1160+ let (view, doc) = current!(cx.editor);
1161+ let focus = view.id;
1161 let mode = doc.mode();
1162 let mode = doc.mode();
1162
1163
1163 if let Some(on_next_key) = self.on_next_key.take() {
1164 if let Some(on_next_key) = self.on_next_key.take() {
@@ -1221,7 +1222,9 @@ impl Component for EditorView {
1221 return EventResult::Ignored(None);
1222 return EventResult::Ignored(None);
1222 }
1223 }
1223 let config = cx.editor.config();
1224 let config = cx.editor.config();
1224− let (view, doc) = current!(cx.editor);
1225+ let view = cx.editor.tree.get_mut(focus);
1226+ let doc = cx.editor.documents.get_mut(&view.doc).unwrap();
1227+
1225 view.ensure_cursor_in_view(doc, config.scrolloff);
1228 view.ensure_cursor_in_view(doc, config.scrolloff);
1226
1229
1227 // Store a history state if not in insert mode. This also takes care of
1230 // Store a history state if not in insert mode. This also takes care of