From a0af0be52859acb2b166482425a8eac82235a7a3 Mon Sep 17 00:00:00 2001 From: Evgeniy Tatarkin Date: Mon, 7 Nov 2022 09:35:53 +0300 Subject: [PATCH] mark document as focused on Editor::focus and Editor::focus_next --- helix-view/src/document.rs | 2 +- helix-view/src/editor.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 449a1a2b7d5b..e56fb55e9ee6 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -773,7 +773,7 @@ impl Document { } /// Mark document as recent used for MRU sorting - pub fn mark_as_used(&mut self) { + pub fn mark_as_focused(&mut self) { self.focused_at = std::time::Instant::now(); } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 05aba1b95630..56303d8777ca 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -993,7 +993,7 @@ impl Editor { let doc = doc_mut!(self, &doc_id); doc.ensure_view_init(view.id); view.sync_changes(doc); - doc.mark_as_used(); + doc.mark_as_focused(); align_view(doc, view, Align::Center); } @@ -1059,7 +1059,7 @@ impl Editor { let view_id = view!(self).id; let doc = doc_mut!(self, &id); doc.ensure_view_init(view_id); - doc.mark_as_used(); + doc.mark_as_focused(); return; } Action::HorizontalSplit | Action::VerticalSplit => { @@ -1081,7 +1081,7 @@ impl Editor { // initialize selection for view let doc = doc_mut!(self, &id); doc.ensure_view_init(view_id); - doc.mark_as_used(); + doc.mark_as_focused(); } } @@ -1274,6 +1274,10 @@ impl Editor { view.sync_changes(doc); } } + + let view = self.tree.get_mut(view_id); + let doc = doc_mut!(self, &view.doc); + doc.mark_as_focused(); } pub fn focus_next(&mut self) {