aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-08-23 05:07:50 +0000
committerBlaž Hrastnik2022-08-23 05:07:50 +0000
commite4c9d4082a139aac3aea4506918171b96e81f5b9 (patch)
treece6ce437ca62211806db3ba66f39d9adebfc83d2 /helix-term/src/ui
parent7b8e4ac95a83513b315af29591ae957ae861605c (diff)
fix: Reset document mode when losing focus
Fixes #3090
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 46218e0d..60cab905 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -976,16 +976,15 @@ impl EditorView {
doc.set_selection(view_id, Selection::point(pos));
}
- editor.tree.focus = view_id;
+ editor.focus(view_id);
return EventResult::Consumed(None);
}
if let Some((coords, view_id)) = gutter_coords_and_view(editor, row, column) {
- editor.tree.focus = view_id;
+ editor.focus(view_id);
- let view = editor.tree.get(view_id);
- let doc = editor.documents.get_mut(&view.doc).unwrap();
+ let (view, doc) = current!(cxt.editor);
let path = match doc.path() {
Some(path) => path.clone(),
@@ -1064,10 +1063,9 @@ impl EditorView {
MouseEventKind::Up(MouseButton::Right) => {
if let Some((coords, view_id)) = gutter_coords_and_view(cxt.editor, row, column) {
- cxt.editor.tree.focus = view_id;
+ cxt.editor.focus(view_id);
- let view = cxt.editor.tree.get(view_id);
- let doc = cxt.editor.documents.get_mut(&view.doc).unwrap();
+ let (view, doc) = current!(cxt.editor);
let line = coords.row + view.offset.row;
if let Ok(pos) = doc.text().try_line_to_char(line) {
doc.set_selection(view_id, Selection::point(pos));
@@ -1100,7 +1098,7 @@ impl EditorView {
if let Some((pos, view_id)) = pos_and_view(editor, row, column) {
let doc = editor.document_mut(editor.tree.get(view_id).doc).unwrap();
doc.set_selection(view_id, Selection::point(pos));
- editor.tree.focus = view_id;
+ cxt.editor.focus(view_id);
commands::MappableCommand::paste_primary_clipboard_before.execute(cxt);
return EventResult::Consumed(None);