diff options
author | Evgeniy Tatarkin | 2023-04-28 16:05:14 +0000 |
---|---|---|
committer | GitHub | 2023-04-28 16:05:14 +0000 |
commit | 6a1bb81f1022533c226395aaa41439ab1ea41dd4 (patch) | |
tree | 2886a0c1f21edd9ada66dcf5341d4eb3626b6928 /helix-view/src/document.rs | |
parent | 9c6c63a2be30252a6207f4aebb5e0f76f746b4c8 (diff) |
Sort the buffer picker by most recent access (#2980)
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r-- | helix-view/src/document.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index eca60026..5ede5bc6 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -169,6 +169,9 @@ pub struct Document { diff_handle: Option<DiffHandle>, version_control_head: Option<Arc<ArcSwap<Box<str>>>>, + + // when document was used for most-recent-used buffer picker + pub focused_at: std::time::Instant, } /// Inlay hints for a single `(Document, View)` combo. @@ -496,6 +499,7 @@ impl Document { diff_handle: None, config, version_control_head: None, + focused_at: std::time::Instant::now(), } } pub fn default(config: Arc<dyn DynAccess<Config>>) -> Self { @@ -908,6 +912,11 @@ impl Document { } } + /// Mark document as recent used for MRU sorting + pub fn mark_as_focused(&mut self) { + self.focused_at = std::time::Instant::now(); + } + /// Remove a view's selection and inlay hints from this document. pub fn remove_view(&mut self, view_id: ViewId) { self.selections.remove(&view_id); |