Skip to content

Commit

Permalink
rename used_at to focused_at, use sort_unstable_by_key
Browse files Browse the repository at this point in the history
  • Loading branch information
estin committed Dec 2, 2022
1 parent 734489c commit f2f2aff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2342,15 +2342,15 @@ fn buffer_picker(cx: &mut Context) {
path: doc.path().cloned(),
is_modified: doc.is_modified(),
is_current: doc.id() == current,
used_at: doc.used_at,
used_at: doc.focused_at,
};

let mut items = cx
.editor
.documents
.values()
.map(|doc| new_meta(doc))
.collect();
.collect::<Vec<BufferMeta>>();

// mru
items.sort_by(|a, b| b.used_at.cmp(&a.used_at));
Expand Down
6 changes: 3 additions & 3 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub struct Document {
diff_handle: Option<DiffHandle>,

// when document was used for most-recent-used buffer picker
pub used_at: std::time::Instant,
pub focused_at: std::time::Instant,
}

use std::{fmt, mem};
Expand Down Expand Up @@ -380,7 +380,7 @@ impl Document {
modified_since_accessed: false,
language_server: None,
diff_handle: None,
used_at: std::time::Instant::now(),
focused_at: std::time::Instant::now(),
}
}

Expand Down Expand Up @@ -774,7 +774,7 @@ impl Document {

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

/// Remove a view's selection from this document.
Expand Down

0 comments on commit f2f2aff

Please sign in to comment.