Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
estin committed Jul 7, 2022
1 parent 6d236c4 commit 0890279
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ impl Document {
}
}

/// Mark document as recent used for MRU sorting
pub fn mark_as_used(&mut self) {
self.used_at = std::time::Instant::now();
}

/// Remove a view's selection from this document.
pub fn remove_view(&mut self, view_id: ViewId) {
self.selections.remove(&view_id);
Expand Down
6 changes: 3 additions & 3 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ impl Editor {

let doc = self.documents.get_mut(&doc_id).unwrap();
doc.ensure_view_init(view.id);
doc.mark_as_used();

// TODO: reuse align_view
let pos = doc
Expand Down Expand Up @@ -786,7 +787,6 @@ impl Editor {
view.last_modified_docs = [Some(view.doc), view.last_modified_docs[0]];
}
}
doc.used_at = std::time::Instant::now();
}

self.replace_document_in_view(view_id, id);
Expand All @@ -797,7 +797,7 @@ impl Editor {
let view_id = view!(self).id;
let doc = self.documents.get_mut(&id).unwrap();
doc.ensure_view_init(view_id);
doc.used_at = std::time::Instant::now();
doc.mark_as_used();
return;
}
Action::HorizontalSplit | Action::VerticalSplit => {
Expand All @@ -813,7 +813,7 @@ impl Editor {
// initialize selection for view
let doc = self.documents.get_mut(&id).unwrap();
doc.ensure_view_init(view_id);
doc.used_at = std::time::Instant::now();
doc.mark_as_used();
}
}

Expand Down

0 comments on commit 0890279

Please sign in to comment.