aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
authorIvan Tham2021-12-02 04:46:57 +0000
committerGitHub2021-12-02 04:46:57 +0000
commite2b428cc2d23965ab7a91809c5705ede0298107d (patch)
tree35484052f5c54deba2ee9e842f693043452bc38f /helix-view/src/editor.rs
parent418b833d2b64ed986cfc84ca023e1a6ca5080008 (diff)
Add last modified file (gm) (#1093)
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index d5913a51..9034d12c 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -369,7 +369,8 @@ impl Editor {
.tree
.traverse()
.any(|(_, v)| v.doc == doc.id && v.id != view.id);
- let view = view_mut!(self);
+
+ let (view, doc) = current!(self);
if remove_empty_scratch {
// Copy `doc.id` into a variable before calling `self.documents.remove`, which requires a mutable
// borrow, invalidating direct access to `doc.id`.
@@ -378,7 +379,16 @@ impl Editor {
} else {
let jump = (view.doc, doc.selection(view.id).clone());
view.jumps.push(jump);
- view.last_accessed_doc = Some(view.doc);
+ // Set last accessed doc if it is a different document
+ if doc.id != id {
+ view.last_accessed_doc = Some(view.doc);
+ // Set last modified doc if modified and last modified doc is different
+ if std::mem::take(&mut doc.modified_since_accessed)
+ && view.last_modified_docs[0] != Some(id)
+ {
+ view.last_modified_docs = [Some(view.doc), view.last_modified_docs[0]];
+ }
+ }
}
let view_id = view.id;