feat: align buffer picker with editor UI
This commit is contained in:
+22
-7
@@ -189,6 +189,13 @@ pub struct PaletteEntry {
|
||||
pub bindings: Vec<String>,
|
||||
pub enabled: bool,
|
||||
pub modes: Vec<Mode>,
|
||||
pub buffer: Option<PaletteBuffer>,
|
||||
}
|
||||
|
||||
pub struct PaletteBuffer {
|
||||
pub id: usize,
|
||||
pub active: bool,
|
||||
pub dirty: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
|
||||
@@ -5474,16 +5481,17 @@ impl Editor {
|
||||
if palette.buffers {
|
||||
palette.entries.clear();
|
||||
for buffer in self.buffers() {
|
||||
let label = sanitize_label(format!(
|
||||
"{}{}{} {}",
|
||||
let label = sanitize_label(buffer.path.map_or_else(
|
||||
|| "[No Name]".into(),
|
||||
|path| path.to_string_lossy().into_owned(),
|
||||
));
|
||||
let searchable = format!(
|
||||
"{}{}{} {label}",
|
||||
buffer.id,
|
||||
if buffer.active { "%" } else { "" },
|
||||
if buffer.dirty { "+" } else { "" },
|
||||
buffer
|
||||
.path
|
||||
.map_or_else(|| Cow::Borrowed("[No Name]"), Path::to_string_lossy),
|
||||
));
|
||||
let searchable = label.to_lowercase();
|
||||
)
|
||||
.to_lowercase();
|
||||
if query
|
||||
.split_whitespace()
|
||||
.all(|token| searchable.contains(token))
|
||||
@@ -5495,6 +5503,11 @@ impl Editor {
|
||||
bindings: Vec::new(),
|
||||
enabled: true,
|
||||
modes: Vec::new(),
|
||||
buffer: Some(PaletteBuffer {
|
||||
id: buffer.id,
|
||||
active: buffer.active,
|
||||
dirty: buffer.dirty,
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -5543,6 +5556,7 @@ impl Editor {
|
||||
Action::LspDefinition | Action::LspHover | Action::LspDiagnostics
|
||||
) || self.document_actions_available()),
|
||||
modes: modes.to_vec(),
|
||||
buffer: None,
|
||||
});
|
||||
}
|
||||
for feature in self.features.values() {
|
||||
@@ -5562,6 +5576,7 @@ impl Editor {
|
||||
bindings: self.palette_bindings(None, command),
|
||||
enabled: self.active.view.mode == Mode::Normal,
|
||||
modes: vec![Mode::Normal],
|
||||
buffer: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user