Skip to content

Commit

Permalink
mark document as focused on Editor::focus and Editor::focus_next
Browse files Browse the repository at this point in the history
  • Loading branch information
estin committed Dec 2, 2022
1 parent f2f2aff commit a0af0be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 7 additions & 3 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 => {
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a0af0be

Please sign in to comment.