@@ -2600,36 +2600,66 @@ fn file_picker(cx: &mut Context) {
2600fn buffer_picker(cx: &mut Context) {
2600fn buffer_picker(cx: &mut Context) {
2601 let current = view!(cx.editor).doc;
2601 let current = view!(cx.editor).doc;
2603+ struct BufferMeta {
2605+ path: Option<PathBuf>,
2611+ fn format(&self) -> Cow<str> {
2615+ .map(helix_core::path::get_relative_path);
2616+ let path = match path.as_deref().and_then(Path::to_str) {
2617+ Some(path) => path,
2618+ None => return Cow::Borrowed("[scratch buffer]"),
2621+ let mut flags = Vec::new();
2622+ if self.is_modified {
2625+ if self.is_current {
2629+ let flag = if flags.is_empty() {
2632+ format!(" ({})", flags.join(""))
2634+ Cow::Owned(format!("{}{}", path, flag))
2638+ let new_meta = |doc: &Document| BufferMeta {
2640+ path: doc.path().cloned(),
2641+ is_modified: doc.is_modified(),
2642+ is_current: doc.id() == current,
2603 let picker = FilePicker::new(
2645 let picker = FilePicker::new(
2604 cx.editor
2646 cx.editor
2605 .documents
2647 .documents
2607− .map(|(id, doc)| (*id, doc.path().cloned()))
2649+ .map(|(_, doc)| new_meta(doc))
2608 .collect(),
2650 .collect(),
2609− move |(id, path): &(DocumentId, Option<PathBuf>)| {
2610− let path = path.as_deref().map(helix_core::path::get_relative_path);
2611− match path.as_ref().and_then(|path| path.to_str()) {
2613− if *id == current {
2614− format!("{} (*)", &path).into()
2651+ BufferMeta::format,
2616− path.to_owned().into()
2619− None => "[scratch buffer]".into(),
2622− |editor: &mut Editor, (id, _path): &(DocumentId, Option<PathBuf>), _action| {
2652+ |editor: &mut Editor, meta, _action| {
2623− editor.switch(*id, Action::Replace);
2653+ editor.switch(meta.id, Action::Replace);
2625− |editor, (id, path)| {
2655+ |editor, meta| {
2626− let doc = &editor.documents.get(id)?;
2656+ let doc = &editor.documents.get(&meta.id)?;
2627 let &view_id = doc.selections().keys().next()?;
2657 let &view_id = doc.selections().keys().next()?;
2628 let line = doc
2658 let line = doc
2629 .selection(view_id)
2659 .selection(view_id)
2630 .primary()
2660 .primary()
2631 .cursor_line(doc.text().slice(..));
2661 .cursor_line(doc.text().slice(..));
2632− Some((path.clone()?, Some((line, line))))
2662+ Some((meta.path.clone()?, Some((line, line))))
2635 cx.push_layer(Box::new(picker));
2665 cx.push_layer(Box::new(picker));