aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 5a75553c..88393ff4 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2473,6 +2473,7 @@ fn buffer_picker(cx: &mut Context) {
path: Option<PathBuf>,
is_modified: bool,
is_current: bool,
+ focused_at: std::time::Instant,
}
impl ui::menu::Item for BufferMeta {
@@ -2505,14 +2506,21 @@ fn buffer_picker(cx: &mut Context) {
path: doc.path().cloned(),
is_modified: doc.is_modified(),
is_current: doc.id() == current,
+ focused_at: doc.focused_at,
};
+ let mut items = cx
+ .editor
+ .documents
+ .values()
+ .map(|doc| new_meta(doc))
+ .collect::<Vec<BufferMeta>>();
+
+ // mru
+ items.sort_unstable_by_key(|item| std::cmp::Reverse(item.focused_at));
+
let picker = FilePicker::new(
- cx.editor
- .documents
- .values()
- .map(|doc| new_meta(doc))
- .collect(),
+ items,
(),
|cx, meta, action| {
cx.editor.switch(meta.id, action);