Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(breadcrumbs): port the click, file and outline pickers

rokartur9e92c788f803
diff --git a/native/crates/app/src/explorer.rs b/native/crates/app/src/explorer.rs
index 78909922883..e1b051e4e34 100644
--- a/native/crates/app/src/explorer.rs
+++ b/native/crates/app/src/explorer.rs
@@ -21,7 +21,7 @@ use icu_collator::preferences::CollationNumericOrdering;
use icu_collator::{Collator, CollatorBorrowed, CollatorPreferences};
/// The `files.exclude` default (files.contribution.ts), matched by name at any depth.
-const EXCLUDED_NAMES: [&str; 6] = [".git", ".svn", ".hg", ".jj", ".DS_Store", "Thumbs.db"];
+pub(crate) const EXCLUDED_NAMES: [&str; 6] = [".git", ".svn", ".hg", ".jj", ".DS_Store", "Thumbs.db"];
pub struct FileTree {
pub workspace: Workspace,
diff --git a/native/crates/app/src/theme.rs b/native/crates/app/src/theme.rs
index 7b722842cb5..673632d25c0 100644
--- a/native/crates/app/src/theme.rs
+++ b/native/crates/app/src/theme.rs
@@ -746,6 +746,8 @@ fn registry_default(key: &str, kind: ThemeKind) -> ColorValue {
),
"breadcrumb.foreground" => (Transparent(&Key("foreground"), 0.8), Transparent(&Key("foreground"), 0.8), Transparent(&Key("foreground"), 0.8)),
"breadcrumb.background" => (Key("editor.background"), Key("editor.background"), Key("editor.background")),
+ "breadcrumb.focusForeground" | "breadcrumb.activeSelectionForeground" => (Lighten(&Key("foreground"), 0.1), Darken(&Key("foreground"), 0.2), Lighten(&Key("foreground"), 0.1)),
+ "breadcrumbPicker.background" => (Key("editorWidget.background"), Key("editorWidget.background"), Key("editorWidget.background")),
"editorGroupHeader.tabsBackground" => (Hex("#252526"), Hex("#F3F3F3"), None),
"editorGroupHeader.connectedTabsBackground" => (
Key("editorGroupHeader.tabsBackground"),
@@ -1094,6 +1096,8 @@ fn hc_light_default(key: &str) -> ColorValue {
"editorOverviewRuler.wordHighlightTextForeground" => Key("editorOverviewRuler.selectionHighlightForeground"),
"breadcrumb.foreground" => Transparent(&Key("foreground"), 0.8),
"breadcrumb.background" => Key("editor.background"),
+ "breadcrumb.focusForeground" | "breadcrumb.activeSelectionForeground" => Lighten(&Key("foreground"), 0.1),
+ "breadcrumbPicker.background" => Key("editorWidget.background"),
"tab.border" => Key("contrastBorder"),
"tab.activeForeground" | "tab.inactiveForeground" => Hex("#292929"),
"textLink.foreground" => Hex("#0F4A85"),
@@ -1637,6 +1641,11 @@ mod tests {
("Default High Contrast", "editorOverviewRuler.border", "#7f7f7f4d"),
("Default High Contrast", "editorLineNumber.foreground", "#ffffffff"),
("Default High Contrast", "breadcrumb.foreground", "#ffffffcc"),
+ ("Dark Modern", "breadcrumb.focusForeground", "#e0e0e0ff"),
+ ("Light Modern", "breadcrumb.activeSelectionForeground", "#2f2f2fff"),
+ ("Default High Contrast Light", "breadcrumb.focusForeground", "#2d2d2dff"),
+ ("Dark Modern", "breadcrumbPicker.background", "#202020ff"),
+ ("Default High Contrast", "breadcrumbPicker.background", "#0c141fff"),
("Dark Modern", "editorOverviewRuler.findMatchForeground", "#d186167d"),
("Dark Modern", "editorOverviewRuler.errorForeground", "#ff1212b3"),
("Dark Modern", "editorOverviewRuler.infoForeground", "#59a4f9ff"),
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index 35ed73a5ede..c95c3c1ea08 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -673,6 +673,7 @@ impl Render for Workbench {
.capture_key_up(cx.listener(|workbench, _: &gpui::KeyUpEvent, _, cx| workbench.reset_keybinding_hold_mode(cx)))
.child(grid)
.children(self.debug_toolbar(window, cx))
+ .children(self.breadcrumbs_picker_widget(window, cx))
.when(self.debug_view.toolbar_drag.is_some(), |root| {
root.on_mouse_move(cx.listener(|workbench, event, window, cx| workbench.drag_debug_toolbar(event, window, cx)))
.on_mouse_up(gpui::MouseButton::Left, cx.listener(|workbench, _, _, _| workbench.end_debug_toolbar_drag()))
diff --git a/native/crates/app/src/workbench/breadcrumbs.rs b/native/crates/app/src/workbench/breadcrumbs.rs
index eb5dbe3936c..1aa388bb845 100644
--- a/native/crates/app/src/workbench/breadcrumbs.rs
+++ b/native/crates/app/src/workbench/breadcrumbs.rs
@@ -1,27 +1,38 @@
-//! breadcrumbsControl.ts focus mode: Focus Breadcrumbs focuses the last item, Left and Right move the focus, Space
-//! reveals the focused item and Escape goes back to the editor (breadcrumbsWidget.ts `_focus`).
+//! breadcrumbsControl.ts: the focus mode (breadcrumbsWidget.ts `_focus`), a click or Enter selecting an item, which
+//! shows its picker (breadcrumbsPicker.ts, breadcrumbs/picker.rs) or with `breadcrumbs.useQuickPick` Quick Open, and
+//! Space revealing the focused item.
+use std::cell::RefCell;
+use std::collections::HashMap;
use std::path::PathBuf;
+use std::rc::Rc;
-use gpui::{Context, FocusHandle, Window};
+use gpui::{Bounds, Context, FocusHandle, Pixels, Window};
use serde_json::json;
use super::Workbench;
use crate::commands::Outcome;
+mod picker;
#[cfg(test)]
mod tests;
+pub(super) use picker::Picker;
+
pub(super) struct Breadcrumbs {
/// The widget's DOM focus, `breadcrumbsActive`.
pub focus: FocusHandle,
/// The group whose breadcrumbs have a focused item, and that item.
focused: Option<(u32, usize)>,
+ /// The picker of the selected item, `_breadcrumbsPickerShowing`.
+ pub picker: Option<Picker>,
+ /// The painted bounds of each group's items, the picker's anchor.
+ pub item_bounds: Rc<RefCell<HashMap<(u32, usize), Bounds<Pixels>>>>,
}
impl Breadcrumbs {
pub fn new(cx: &mut gpui::App) -> Self {
- Self { focus: cx.focus_handle(), focused: None }
+ Self { focus: cx.focus_handle(), focused: None, picker: None, item_bounds: Rc::default() }
}
}
@@ -29,29 +40,58 @@ impl Breadcrumbs {
enum BreadcrumbElement {
/// The resource's scheme and path.
File(String, PathBuf),
- Folder,
+ /// A folder of the path and whether it is a FileKind.ROOT_FOLDER (`~` or a workspace folder).
+ Folder(PathBuf, bool),
/// An outline symbol by id; the `…` item and a notebook's cells have none.
Symbol(Option<String>),
}
+/// `IBreadcrumbsItemEvent.payload`: what selecting an item does.
+#[derive(Clone, Copy, PartialEq)]
+enum Payload {
+ /// `Payload_Pick` or a click at the window x: the item's picker.
+ Pick(Option<f32>),
+ /// `Payload_Reveal`.
+ Reveal,
+}
+
impl Workbench {
pub(super) fn register_breadcrumbs_commands(&mut self) {
- self.commands.register("breadcrumbs.focus", |workbench, _, window, cx| {
- workbench.focus_breadcrumbs(window, cx);
+ for (id, select) in [("breadcrumbs.focus", false), ("breadcrumbs.focusAndSelect", true)] {
+ self.commands.register(id, move |workbench, _, window, cx| {
+ workbench.focus_and_select_breadcrumbs(select, window, cx);
+ Outcome::done()
+ });
+ }
+ // Enabled only while the breadcrumbs are off, which it turns on before it focuses and selects.
+ self.commands.register("breadcrumbs.toggleToOn", |workbench, _, window, cx| {
+ if workbench.setting("breadcrumbs.enabled") == json!(false) {
+ workbench.update_user_setting("breadcrumbs.enabled", json!(true));
+ }
+ workbench.focus_and_select_breadcrumbs(true, window, cx);
Outcome::done()
});
- for (id, step) in [("breadcrumbs.focusNext", 1), ("breadcrumbs.focusPrevious", -1)] {
- self.commands.register(id, move |workbench, _, _, cx| {
- workbench.move_breadcrumbs_focus(step, cx);
+ for (id, step) in [("breadcrumbs.focusNext", 1), ("breadcrumbs.focusPrevious", -1), ("breadcrumbs.focusNextWithPicker", 1), ("breadcrumbs.focusPreviousWithPicker", -1)] {
+ self.commands.register(id, move |workbench, _, window, cx| {
+ workbench.move_breadcrumbs_focus(step, window, cx);
Outcome::done()
});
}
+ self.commands.register("breadcrumbs.selectFocused", |workbench, _, window, cx| {
+ workbench.select_focused_breadcrumb(Payload::Pick(None), window, cx);
+ Outcome::done()
+ });
self.commands.register("breadcrumbs.revealFocused", |workbench, _, window, cx| {
- workbench.reveal_focused_breadcrumb(window, cx);
+ workbench.select_focused_breadcrumb(Payload::Reveal, window, cx);
+ Outcome::done()
+ });
+ self.commands.register("breadcrumbs.revealFocusedFromTreeAside", |workbench, _, window, cx| {
+ workbench.open_breadcrumbs_picker_row(true, window, cx);
Outcome::done()
});
self.commands.register("breadcrumbs.selectEditor", |workbench, _, window, cx| {
workbench.breadcrumbs.focused = None;
+ workbench.hide_breadcrumbs_picker(false, window, cx);
workbench.focus_group(workbench.editors.id, window, cx);
Outcome::done()
});
@@ -66,39 +106,98 @@ impl Workbench {
self.breadcrumbs_possible(editor) && !self.drawing_compact_part() && self.setting("breadcrumbs.enabled") != json!(false)
}
+ /// `_updateCkBreadcrumbsActive`: the widget has the focus or its picker shows.
+ pub(super) fn breadcrumbs_active(&self, window: &Window) -> bool {
+ self.breadcrumbs.focus.is_focused(window) || self.breadcrumbs.picker.is_some()
+ }
+
/// The focused item of the breadcrumbs of the group being drawn.
pub(super) fn breadcrumbs_focused(&self) -> Option<usize> {
self.breadcrumbs.focused.filter(|(group, _)| *group == self.editors.id).map(|(_, index)| index)
}
- /// `focusAndSelectHandler` without the selection: the active group's last item.
- fn focus_breadcrumbs(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ /// The item of the group being drawn whose picker shows, `.selected`.
+ pub(super) fn breadcrumbs_selected(&self) -> Option<usize> {
+ self.breadcrumbs.picker.as_ref().filter(|picker| picker.group == self.editors.id).map(|picker| picker.item)
+ }
+
+ /// `focusAndSelectHandler`: the active group's last item, and with `select` its picker.
+ fn focus_and_select_breadcrumbs(&mut self, select: bool, window: &mut Window, cx: &mut Context<Self>) {
let Some(editor) = self.editors.active() else { return };
if !self.breadcrumbs_visible(editor) {
return;
}
let last = self.breadcrumb_elements().len() - 1;
- self.breadcrumbs.focused = Some((self.editors.id, last));
+ self.focus_breadcrumb(last, window, cx);
+ if select {
+ self.select_breadcrumb(last, Payload::Pick(None), window, cx);
+ }
+ }
+
+ /// breadcrumbsWidget.ts `_focus` and `_onFocusEvent`: with a picker showing, the newly focused item shows its own.
+ fn focus_breadcrumb(&mut self, index: usize, window: &mut Window, cx: &mut Context<Self>) {
+ self.breadcrumbs.focused = Some((self.editors.id, index));
window.focus(&self.breadcrumbs.focus, cx);
+ if self.breadcrumbs.picker.is_some() {
+ self.select_breadcrumb(index, Payload::Pick(None), window, cx);
+ }
cx.notify();
}
/// breadcrumbsWidget.ts `focusNext` and `focusPrev`: the focus stops at either end.
- fn move_breadcrumbs_focus(&mut self, step: isize, cx: &mut Context<Self>) {
+ fn move_breadcrumbs_focus(&mut self, step: isize, window: &mut Window, cx: &mut Context<Self>) {
let Some(focused) = self.breadcrumbs_focused() else { return };
let Some(next) = focused.checked_add_signed(step).filter(|next| *next < self.breadcrumb_elements().len()) else { return };
- self.breadcrumbs.focused = Some((self.editors.id, next));
- cx.notify();
+ self.focus_breadcrumb(next, window, cx);
}
- /// `_onSelectEvent` with `Payload_Reveal` and `_revealInEditor`: a file opens in the group, a symbol is revealed at
- /// the start of its name; a folder focuses the next item, whose picker is not ported.
- fn reveal_focused_breadcrumb(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ fn select_focused_breadcrumb(&mut self, payload: Payload, window: &mut Window, cx: &mut Context<Self>) {
let Some(focused) = self.breadcrumbs_focused() else { return };
- let element = self.breadcrumb_elements().swap_remove(focused);
+ self.select_breadcrumb(focused, payload, window, cx);
+ }
+
+ /// breadcrumbsWidget.ts `_onClick`: a click focuses and selects the item under the pointer; a click on the item
+ /// whose picker shows closes it (`_breadcrumbsPickerIgnoreOnceItem`).
+ pub(super) fn breadcrumb_clicked(&mut self, index: usize, x: f32, window: &mut Window, cx: &mut Context<Self>) {
+ if self.breadcrumbs_selected() == Some(index) {
+ return self.hide_breadcrumbs_picker(false, window, cx);
+ }
+ self.breadcrumbs.focused = Some((self.editors.id, index));
+ window.focus(&self.breadcrumbs.focus, cx);
+ self.select_breadcrumb(index, Payload::Pick(Some(x)), window, cx);
+ }
+
+ /// `_onSelectEvent`: Reveal opens a file or reveals a symbol, else `breadcrumbs.useQuickPick` opens Quick Open,
+ /// else the item's picker shows.
+ fn select_breadcrumb(&mut self, index: usize, payload: Payload, window: &mut Window, cx: &mut Context<Self>) {
+ let element = self.breadcrumb_elements().swap_remove(index);
+ let group = self.editors.id;
+ if payload == Payload::Reveal {
+ return self.reveal_breadcrumb(index, element, window, cx);
+ }
+ if self.setting("breadcrumbs.useQuickPick") == json!(true) {
+ self.breadcrumbs.focused = None;
+ self.hide_breadcrumbs_picker(false, window, cx);
+ let prefix = if matches!(element, BreadcrumbElement::Symbol(_)) { "@" } else { "" };
+ return self.show_quick_access(prefix, false, false, window, cx);
+ }
+ let Payload::Pick(click_x) = payload else { unreachable!("Reveal returned above") };
+ self.breadcrumbs.picker = None;
+ let picker = self.new_breadcrumbs_picker(group, index, element, click_x, window, cx);
+ window.focus(&picker.focus, cx);
+ self.breadcrumbs.picker = Some(picker);
+ cx.notify();
+ }
+
+ /// `_revealInEditor`: a file opens in the group, a symbol is revealed at the start of its name, and a folder
+ /// focuses and picks the next item.
+ fn reveal_breadcrumb(&mut self, index: usize, element: BreadcrumbElement, window: &mut Window, cx: &mut Context<Self>) {
let group = self.editors.id;
match element {
- BreadcrumbElement::Folder => return self.move_breadcrumbs_focus(1, cx),
+ BreadcrumbElement::Folder(..) => {
+ self.breadcrumbs.focused = Some((group, index + 1));
+ return self.select_breadcrumb(index + 1, Payload::Pick(None), window, cx);
+ }
BreadcrumbElement::File(scheme, path) => {
self.breadcrumbs.focused = None;
self.focus_group(group, window, cx);
@@ -123,8 +222,10 @@ impl Workbench {
let path = self.breadcrumbs_resource(editor, notebook_path);
// shortcut: a notebook's or custom editor's resource opens as a file, upgrade when breadcrumbs keep the URI.
let scheme = if path == editor.document().path { editor.document().scheme.clone() } else { "file".into() };
- let (segments, _, _) = self.breadcrumb_file_segments(&path);
- let mut elements: Vec<_> = (1..segments.len()).map(|_| BreadcrumbElement::Folder).collect();
+ let (segments, _, has_root_folder) = self.breadcrumb_file_segments(&path);
+ let file = segments.len() - 1;
+ // Each item above the file is the folder as many levels up, `~` the home and a workspace's name its folder.
+ let mut elements: Vec<_> = (0..file).map(|index| BreadcrumbElement::Folder(path.ancestors().nth(file - index).expect("an ancestor per item").to_path_buf(), has_root_folder && index == 0)).collect();
elements.push(BreadcrumbElement::File(scheme, path));
match notebook_items {
Some(items) => elements.extend(items.iter().map(|_| BreadcrumbElement::Symbol(None))),
diff --git a/native/crates/app/src/workbench/breadcrumbs/picker.rs b/native/crates/app/src/workbench/breadcrumbs/picker.rs
new file mode 100644
index 00000000000..016e3af954c
--- /dev/null
+++ b/native/crates/app/src/workbench/breadcrumbs/picker.rs
@@ -0,0 +1,452 @@
+//! breadcrumbsPicker.ts: the tree below a selected item. A path item lists the files of its folder (the workspace's
+//! folders for a root folder item) with its own file focused; a symbol item lists the outline with its symbol
+//! revealed and focused. Opening a file or a symbol closes the picker; losing the focus closes it unpicked.
+
+use std::collections::HashSet;
+use std::path::PathBuf;
+
+use gpui::{AnyElement, Bounds, ClickEvent, Context, FocusHandle, MouseButton, PathBuilder, Pixels, ScrollHandle, Subscription, Window, anchored, canvas, deferred, div, point, prelude::*, px};
+use serde_json::json;
+
+use super::{BreadcrumbElement, Workbench};
+use crate::outline_model::{OutlineChildren, OutlineElement};
+use crate::workbench::outline_actions::SortOrder;
+use crate::workbench::outline_pane::{self, Status};
+
+/// breadcrumbsPicker.ts `FileVirtualDelegate.getHeight`, the outline's rows too.
+const ROW_HEIGHT: f32 = 22.;
+/// breadcrumbsControl.ts `pickerArrowSize`.
+const ARROW_SIZE: f32 = 8.;
+
+pub(in crate::workbench) struct Picker {
+ pub group: u32,
+ pub item: usize,
+ pub focus: FocusHandle,
+ /// The window x of the click that showed the picker; the keyboard points the arrow 30% into the item.
+ click_x: Option<f32>,
+ source: Source,
+ /// The keys of the expanded folders or symbols.
+ expanded: HashSet<String>,
+ /// The key of the focused row.
+ pub(super) focused: Option<String>,
+ scroll: ScrollHandle,
+ _focus_out: Subscription,
+}
+
+enum Source {
+ /// `BreadcrumbsFilePicker`: the children of the folder, or the workspace's folders when `None`.
+ Files(Option<PathBuf>),
+ /// `BreadcrumbsOutlinePicker`: the outline of the model, whose resource opens to the side.
+ Outline { model_id: u32, scheme: String, path: PathBuf },
+}
+
+pub(super) struct Row<'a> {
+ pub(super) key: String,
+ depth: usize,
+ /// `None` for a row without children (`hideTwistiesOfChildlessElements`), else whether it is expanded.
+ expanded: Option<bool>,
+ target: Target<'a>,
+}
+
+enum Target<'a> {
+ /// A folder and whether it is a workspace folder (FileKind.ROOT_FOLDER).
+ Folder(PathBuf, bool),
+ File(PathBuf),
+ Group(&'a str),
+ Symbol(&'a OutlineElement),
+}
+
+impl Workbench {
+ /// `_onSelectEvent`'s `showContextView` and `_setInput`: the picker of `element`, its own row revealed and focused.
+ pub(super) fn new_breadcrumbs_picker(&mut self, group: u32, item: usize, element: BreadcrumbElement, click_x: Option<f32>, window: &mut Window, cx: &mut Context<Self>) -> Picker {
+ let (source, expanded, focused) = match element {
+ BreadcrumbElement::Folder(path, true) => {
+ let key = path.to_string_lossy().into_owned();
+ (Source::Files(None), HashSet::new(), Some(key))
+ }
+ BreadcrumbElement::Folder(path, false) | BreadcrumbElement::File(_, path) => {
+ let key = path.to_string_lossy().into_owned();
+ (Source::Files(path.parent().map(PathBuf::from)), HashSet::new(), Some(key))
+ }
+ BreadcrumbElement::Symbol(id) => {
+ let editor = self.active_text_editor_control().or(self.editors.active()).expect("breadcrumbs of an editor");
+ let (model_id, scheme, path) = (editor.model_id, editor.document().scheme.clone(), editor.document().path.clone());
+ // `tree.reveal(input.element)` expands the element's parents.
+ let expanded = match (&self.outline_pane.status, &id) {
+ (Status::Ready { outline, .. }, Some(id)) => outline.path_to(id).into_iter().flatten().map(|element| element.id.clone()).collect(),
+ _ => HashSet::new(),
+ };
+ (Source::Outline { model_id, scheme, path }, expanded, id)
+ }
+ };
+ let focus = cx.focus_handle();
+ let focus_out = cx.on_focus_out(&focus, window, |workbench, _, window, cx| workbench.hide_breadcrumbs_picker(false, window, cx));
+ let picker = Picker { group, item, focus, click_x, source, expanded, focused, scroll: ScrollHandle::new(), _focus_out: focus_out };
+ let index = self.breadcrumbs_picker_rows(&picker).iter().position(|row| Some(&row.key) == picker.focused.as_ref());
+ if let Some(index) = index {
+ picker.scroll.scroll_to_item(index);
+ }
+ picker
+ }
+
+ /// `hideContextView`: the item loses its focus and selection unless the focus moved on to another item.
+ pub(super) fn hide_breadcrumbs_picker(&mut self, keep_focus: bool, _window: &mut Window, cx: &mut Context<Self>) {
+ if self.breadcrumbs.picker.take().is_none() {
+ return;
+ }
+ if !keep_focus {
+ self.breadcrumbs.focused = None;
+ }
+ cx.notify();
+ }
+
+ pub(super) fn breadcrumbs_picker_rows<'a>(&'a self, picker: &Picker) -> Vec<Row<'a>> {
+ match &picker.source {
+ Source::Files(folder) => {
+ let mut rows = Vec::new();
+ match folder {
+ Some(folder) => self.push_picker_files(&mut rows, folder.clone(), 0, &picker.expanded),
+ None => {
+ for folder in self.workspace().map(|workspace| workspace.folders.as_slice()).unwrap_or_default() {
+ let key = folder.path.to_string_lossy().into_owned();
+ let expanded = picker.expanded.contains(&key);
+ rows.push(Row { key, depth: 0, expanded: Some(expanded), target: Target::Folder(folder.path.clone(), true) });
+ if expanded {
+ self.push_picker_files(&mut rows, folder.path.clone(), 1, &picker.expanded);
+ }
+ }
+ }
+ }
+ rows
+ }
+ Source::Outline { model_id, .. } => {
+ let Status::Ready { model_id: shown, outline, .. } = &self.outline_pane.status else { return Vec::new() };
+ if shown != model_id {
+ return Vec::new();
+ }
+ let sort_by = match self.setting("breadcrumbs.symbolSortOrder").as_str() {
+ Some("name") => SortOrder::ByName,
+ Some("type") => SortOrder::ByKind,
+ _ => SortOrder::ByPosition,
+ };
+ let expanded = |id: &str| picker.expanded.contains(id);
+ let shown = |element: &OutlineElement| self.shows_symbol_kind("breadcrumbs", element.symbol.kind);
+ let mut rows = Vec::new();
+ match outline.children {
+ OutlineChildren::Elements => outline_pane::push_elements(&mut rows, &outline.groups[0].children, 0, sort_by, &expanded, &shown),
+ OutlineChildren::Groups => {
+ for group in &outline.groups {
+ rows.push(outline_pane::Row { depth: 0, id: &group.id, group: Some(&group.label), element: None, has_children: true });
+ if expanded(&group.id) {
+ outline_pane::push_elements(&mut rows, &group.children, 1, sort_by, &expanded, &shown);
+ }
+ }
+ }
+ }
+ rows.into_iter()
+ .map(|row| {
+ let target = match (row.group, row.element) {
+ (Some(label), _) => Target::Group(label),
+ (None, element) => Target::Symbol(element.expect("a row is a group or an element")),
+ };
+ Row { key: row.id.to_string(), depth: row.depth, expanded: row.has_children.then(|| expanded(row.id)), target }
+ })
+ .collect()
+ }
+ }
+ }
+
+ /// `FileDataSource.getChildren` in `FileSorter` order: folders first, then by name; `FileFilter` hides the
+ /// `files.exclude` default names.
+ fn push_picker_files<'a>(&self, rows: &mut Vec<Row<'a>>, folder: PathBuf, depth: usize, expanded: &HashSet<String>) {
+ let Ok(entries) = std::fs::read_dir(&folder) else { return };
+ let mut children: Vec<(String, PathBuf, bool)> = entries
+ .flatten()
+ .map(|entry| (entry.file_name().to_string_lossy().into_owned(), entry.path(), entry.path().is_dir()))
+ .filter(|(name, _, _)| !crate::explorer::EXCLUDED_NAMES.contains(&name.as_str()))
+ .collect();
+ children.sort_by(|a, b| b.2.cmp(&a.2).then_with(|| crate::explorer::compare_file_names(&a.0, &b.0)));
+ for (_, path, is_dir) in children {
+ let key = path.to_string_lossy().into_owned();
+ if !is_dir {
+ rows.push(Row { key, depth, expanded: None, target: Target::File(path) });
+ continue;
+ }
+ let is_expanded = expanded.contains(&key);
+ rows.push(Row { key, depth, expanded: Some(is_expanded), target: Target::Folder(path.clone(), false) });
+ if is_expanded {
+ self.push_picker_files(rows, path, depth + 1, expanded);
+ }
+ }
+ }
+
+ /// listWidget.ts and abstractTree.ts `KeyboardController`: the tree takes its unmodified keys before the
+ /// keybindings, so Left and Right expand and collapse here where `breadcrumbs.focusPrevious` and `focusNext` would run.
+ pub(in crate::workbench) fn breadcrumbs_picker_key(&mut self, keystroke: &gpui::Keystroke, window: &mut Window, cx: &mut Context<Self>) -> bool {
+ let command = match keystroke.key.as_str() {
+ _ if keystroke.modifiers.modified() => return false,
+ "up" => "list.focusUp",
+ "down" => "list.focusDown",
+ "home" => "list.focusFirst",
+ "end" => "list.focusLast",
+ "left" => "list.collapse",
+ "right" => "list.expand",
+ "space" => "list.toggleExpand",
+ "enter" => "list.select",
+ _ => return false,
+ };
+ self.breadcrumbs_picker_list_command(command, window, cx)
+ }
+
+ /// The list commands while the picker has the focus: listWidget.ts's focus moves and abstractTree.ts's expand and
+ /// collapse; `list.select` opens the focused file or symbol.
+ pub(in crate::workbench) fn breadcrumbs_picker_list_command(&mut self, id: &str, window: &mut Window, cx: &mut Context<Self>) -> bool {
+ let Some(picker) = self.breadcrumbs.picker.as_ref().filter(|picker| picker.focus.is_focused(window)) else { return false };
+ let rows: Vec<(String, usize, Option<bool>)> = self.breadcrumbs_picker_rows(picker).into_iter().map(|row| (row.key, row.depth, row.expanded)).collect();
+ if rows.is_empty() {
+ return true;
+ }
+ let focus = picker.focused.as_ref().and_then(|focused| rows.iter().position(|row| row.0 == *focused));
+ let last = rows.len() - 1;
+ let target = match id {
+ "list.focusDown" | "list.focusAnyDown" => focus.map_or(0, |index| (index + 1).min(last)),
+ "list.focusUp" | "list.focusAnyUp" => focus.map_or(0, |index| index.saturating_sub(1)),
+ "list.focusFirst" | "list.focusAnyFirst" => 0,
+ "list.focusLast" | "list.focusAnyLast" => last,
+ "list.select" => {
+ let Some(index) = focus else { return true };
+ self.open_breadcrumbs_picker_index(index, false, false, window, cx);
+ return true;
+ }
+ "list.expand" | "list.collapse" | "list.toggleExpand" => {
+ let Some(index) = focus else { return true };
+ let (key, depth, expanded) = rows[index].clone();
+ let child = rows.get(index + 1).filter(|child| child.1 > depth).map(|child| child.0.clone());
+ let parent = rows[..index].iter().rposition(|parent| parent.1 < depth).map(|parent| rows[parent].0.clone());
+ let picker = self.breadcrumbs.picker.as_mut().expect("checked above");
+ match (id, expanded) {
+ ("list.toggleExpand", Some(expanded)) | ("list.expand", Some(expanded @ false)) | ("list.collapse", Some(expanded @ true)) => {
+ if expanded {
+ picker.expanded.remove(&key);
+ } else {
+ picker.expanded.insert(key);
+ }
+ }
+ ("list.expand", Some(true)) => picker.focused = child.or(picker.focused.take()),
+ ("list.collapse", _) => picker.focused = parent.or(picker.focused.take()),
+ _ => {}
+ }
+ cx.notify();
+ return true;
+ }
+ _ => return false,
+ };
+ let picker = self.breadcrumbs.picker.as_mut().expect("checked above");
+ picker.focused = Some(rows[target].0.clone());
+ picker.scroll.scroll_to_item(target);
+ cx.notify();
+ true
+ }
+
+ /// `breadcrumbs.revealFocusedFromTreeAside` and a modified click: the focused row opens, pinned, to the side.
+ pub(super) fn open_breadcrumbs_picker_row(&mut self, side_by_side: bool, window: &mut Window, cx: &mut Context<Self>) {
+ let Some(picker) = self.breadcrumbs.picker.as_ref().filter(|picker| picker.focus.is_focused(window)) else { return };
+ let Some(index) = self.breadcrumbs_picker_rows(picker).iter().position(|row| Some(&row.key) == picker.focused.as_ref()) else { return };
+ self.open_breadcrumbs_picker_index(index, side_by_side, side_by_side, window, cx);
+ }
+
+ /// `_revealElement`: a file or a symbol opens and closes the picker as picked; a folder does nothing.
+ fn open_breadcrumbs_picker_index(&mut self, index: usize, side_by_side: bool, pinned: bool, window: &mut Window, cx: &mut Context<Self>) {
+ let picker = self.breadcrumbs.picker.as_ref().expect("an open picker");
+ let group = picker.group;
+ let outline_resource = match &picker.source {
+ Source::Outline { scheme, path, .. } => Some(crate::editor::uri_value(scheme, path)),
+ Source::Files(_) => None,
+ };
+ let opened = match &self.breadcrumbs_picker_rows(picker)[index].target {
+ Target::File(path) => Some((crate::editor::uri_value("file", path), None)),
+ Target::Symbol(element) => Some((outline_resource.expect("a symbol of the outline picker"), Some((element.id.clone(), element.symbol.selection_range.start)))),
+ Target::Folder(..) | Target::Group(_) => None,
+ };
+ let Some((resource, symbol)) = opened else { return };
+ self.hide_breadcrumbs_picker(false, window, cx);
+ self.focus_group(group, window, cx);
+ if side_by_side {
+ // documentSymbolsOutline.ts `reveal`: the selection range collapsed to its start, near the top if outside.
+ let mut options = json!({ "pinned": pinned, "preserveFocus": false, "position": crate::workbench::webview_panels::SIDE_GROUP });
+ if let Some((_, (line, column))) = symbol {
+ options["selection"] = json!({ "startLineNumber": line, "startColumn": column, "endLineNumber": line, "endColumn": column });
+ options["selectionRevealType"] = json!(3);
+ }
+ drop(self.try_show_text_document(&resource, &options, window, cx));
+ return;
+ }
+ match symbol {
+ Some((id, _)) => self.reveal_outline_symbol(&id, false, window, cx),
+ None => {
+ let Ok(("file", path)) = crate::workbench::host_requests::uri_parts(&resource) else { return };
+ self.open_file_in_active_group("file", path, pinned, window, cx);
+ }
+ }
+ }
+
+ fn breadcrumbs_picker_row_clicked(&mut self, index: usize, event: &ClickEvent, window: &mut Window, cx: &mut Context<Self>) {
+ let Some(picker) = self.breadcrumbs.picker.as_mut() else { return };
+ window.focus(&picker.focus, cx);
+ let rows = self.breadcrumbs_picker_rows(self.breadcrumbs.picker.as_ref().expect("checked above"));
+ let Some(row) = rows.get(index) else { return };
+ let (key, expanded, is_symbol) = (row.key.clone(), row.expanded, matches!(row.target, Target::Symbol(_) | Target::Group(_)));
+ let picker = self.breadcrumbs.picker.as_mut().expect("checked above");
+ picker.focused = Some(key.clone());
+ cx.notify();
+ // The file tree expands a folder on a click on its row, the outline only on its twistie (`expandOnlyOnTwistieClick`).
+ if let (Some(expanded), false) = (expanded, is_symbol) {
+ if expanded {
+ picker.expanded.remove(&key);
+ } else {
+ picker.expanded.insert(key);
+ }
+ return;
+ }
+ // listService.ts `onPointer`: a middle click pins, Cmd, Ctrl or Alt opens to the side.
+ let modifiers = event.modifiers();
+ let side_by_side = modifiers.platform || modifiers.control || modifiers.alt;
+ let pinned = matches!(event, ClickEvent::Mouse(mouse) if mouse.down.button == MouseButton::Middle);
+ self.open_breadcrumbs_picker_index(index, side_by_side, pinned, window, cx);
+ }
+
+ fn toggle_breadcrumbs_picker_row(&mut self, key: &str, cx: &mut Context<Self>) {
+ let Some(picker) = self.breadcrumbs.picker.as_mut() else { return };
+ if !picker.expanded.remove(key) {
+ picker.expanded.insert(key.to_string());
+ }
+ cx.notify();
+ }
+
+ /// The picker below its item: breadcrumbsControl.ts `getAnchor` and breadcrumbsPicker.ts `show` and `_layout`.
+ pub(in crate::workbench) fn breadcrumbs_picker_widget(&self, window: &Window, cx: &mut Context<Self>) -> Option<AnyElement> {
+ let picker = self.breadcrumbs.picker.as_ref()?;
+ let item: Bounds<Pixels> = self.breadcrumbs.item_bounds.borrow().get(&(picker.group, picker.item)).copied()?;
+ let viewport = window.viewport_size();
+ let max_inner_width = f32::from(viewport.width) - 8.;
+ let width = max_inner_width.min((max_inner_width / 4.17).max(240.));
+ let y = f32::from(item.bottom()) + ARROW_SIZE;
+ let mut max_height = (f32::from(viewport.height) * 0.7).min(300.);
+ if y + max_height >= f32::from(viewport.height) {
+ // Room for the shadow and the status bar.
+ max_height = f32::from(viewport.height) - y - 30.;
+ }
+ let mut x = f32::from(item.left());
+ if x + width >= max_inner_width {
+ x = max_inner_width - width;
+ }
+ let arrow_offset = match picker.click_x {
+ Some(click_x) => {
+ let max_arrow_offset = width - 2. * ARROW_SIZE;
+ let mut offset = click_x - x;
+ if offset > max_arrow_offset {
+ x = (max_inner_width - width).min(x + offset - max_arrow_offset);
+ offset = max_arrow_offset;
+ }
+ offset
+ }
+ None => f32::from(item.left()) + f32::from(item.size.width) * 0.3 - x,
+ }
+ .max(0.);
+ let rows = self.breadcrumbs_picker_rows(picker);
+ let tree_height = (max_height - 2. * ARROW_SIZE).min(rows.len() as f32 * ROW_HEIGHT);
+ let background = self.color("breadcrumbPicker.background");
+ let tree_focused = picker.focus.is_focused(window);
+ let indent = self.tree_indent();
+ let foreground = self.color("foreground");
+ let icon_foreground = self.foreground_or("icon.foreground");
+ let focus_outline = self.theme.color("list.focusOutline").or(self.theme.color("focusBorder")).filter(|_| tree_focused);
+ let focus_background = self.theme.color("list.focusBackground").filter(|_| tree_focused);
+ let row_elements: Vec<AnyElement> = rows
+ .iter()
+ .enumerate()
+ .map(|(index, row)| {
+ let focused = picker.focused.as_ref() == Some(&row.key);
+ let toggled = row.key.clone();
+ let twistie = match row.expanded {
+ Some(expanded) => self
+ .icon(if expanded { "chevron-down" } else { "chevron-right" }, 16., 16., icon_foreground)
+ .id(("breadcrumbs-picker-twistie", index))
+ .on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| {
+ cx.stop_propagation();
+ workbench.toggle_breadcrumbs_picker_row(&toggled, cx);
+ })),
+ None => div().id(("breadcrumbs-picker-twistie", index)).size(px(16.)),
+ };
+ let content = match &row.target {
+ Target::Folder(path, is_root) => {
+ let folder = crate::file_icons::FolderIcon { path, is_root: *is_root, expanded: row.expanded == Some(true) };
+ let icon = self.file_icons.as_ref().and_then(|icons| icons.folder_icon(folder, self.theme.kind, 13., ROW_HEIGHT, foreground));
+ div().flex().items_center().children(icon.map(|icon| icon.mr(px(6.)))).child(file_name(path))
+ }
+ Target::File(path) => {
+ let icon = self.file_icons.as_ref().and_then(|icons| icons.file_icon(path, self.languages.language_of(path, ""), self.theme.kind, 13., ROW_HEIGHT, foreground));
+ div().flex().items_center().children(icon.map(|icon| icon.mr(px(6.)))).child(file_name(path))
+ }
+ Target::Group(label) => div().child(label.to_string()),
+ Target::Symbol(element) => self.outline_element_label(element, &[], focused, None).flex().items_center(),
+ };
+ div()
+ .id(("breadcrumbs-picker-row", index))
+ .debug_selector(move || format!("breadcrumbs-picker-row-{index}"))
+ .relative()
+ .h(px(ROW_HEIGHT))
+ .flex_none()
+ .flex()
+ .items_center()
+ .cursor_pointer()
+ // abstractTree.ts `renderElement`: the twistie's padding-left is the indent of the row's depth.
+ .pl(px(indent * row.depth as f32))
+ .hover(|row| row.bg(self.color("list.hoverBackground")))
+ .when_some(focus_background.filter(|_| focused), |row, color| row.bg(color))
+ .when_some(focus_outline.filter(|_| focused), |row, color| row.child(div().absolute().inset_0().border_1().border_color(color)))
+ .child(twistie.flex_none().mr(px(6.)))
+ .child(content.flex_1().min_w_0().overflow_hidden().whitespace_nowrap())
+ .on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| workbench.breadcrumbs_picker_row_clicked(index, event, window, cx)))
+ .into_any_element()
+ })
+ .collect();
+ let arrow = canvas(
+ |_, _, _| (),
+ move |bounds, _, window, _| {
+ // The arrow is a CSS border triangle: the 8px bottom border of a 16px box, pointing up at the item.
+ let (left, bottom) = (bounds.origin.x, bounds.origin.y + px(ARROW_SIZE));
+ let mut path = PathBuilder::fill();
+ path.move_to(point(left, bottom));
+ path.line_to(point(left + px(2. * ARROW_SIZE), bottom));
+ path.line_to(point(left + px(ARROW_SIZE), bounds.origin.y));
+ path.close();
+ if let Ok(path) = path.build() {
+ window.paint_path(path, background);
+ }
+ },
+ )
+ .ml(px(arrow_offset))
+ .w(px(2. * ARROW_SIZE))
+ .h(px(ARROW_SIZE));
+ let tree = div()
+ .id("breadcrumbs-picker-tree")
+ .track_focus(&picker.focus)
+ .w(px(width))
+ .pt(px(2.))
+ .bg(background)
+ .rounded(px(3.))
+ .border_1()
+ .border_color(self.color("widget.border"))
+ // --vscode-shadow-lg, its 12px blur as a sigma of 6.
+ .shadow(vec![gpui::BoxShadow { color: gpui::rgba(0x00000024).into(), offset: point(px(0.), px(0.)), blur_radius: px(6.), spread_radius: px(0.), inset: false }])
+ .text_color(foreground)
+ .child(div().id("breadcrumbs-picker-rows").h(px(tree_height)).overflow_y_scroll().track_scroll(&picker.scroll).children(row_elements));
+ let widget = div().occlude().flex().flex_col().child(arrow).child(tree);
+ Some(deferred(anchored().position(point(px(x), px(y - ARROW_SIZE))).child(widget)).with_priority(1).into_any_element())
+ }
+}
+
+fn file_name(path: &std::path::Path) -> String {
+ path.file_name().map_or_else(|| path.to_string_lossy().into_owned(), |name| name.to_string_lossy().into_owned())
+}
diff --git a/native/crates/app/src/workbench/breadcrumbs/tests.rs b/native/crates/app/src/workbench/breadcrumbs/tests.rs
index 069efd8748e..4d1354fbf27 100644
--- a/native/crates/app/src/workbench/breadcrumbs/tests.rs
+++ b/native/crates/app/src/workbench/breadcrumbs/tests.rs
@@ -45,3 +45,123 @@ fn the_keyboard_focuses_moves_through_and_reveals_the_breadcrumbs(cx: &mut TestA
cx.simulate_keystrokes("cmd-shift-; escape");
assert_eq!(state(cx), (None, false, true, Position::new(0, 6)), "Escape focuses the editor");
}
+
+/// breadcrumbsControl.ts `focusAndSelect` and breadcrumbsPicker.ts `BreadcrumbsOutlinePicker`: Shift+Cmd+. shows the
+/// outline picker of the last item with its symbol focused and its parents expanded; Up and Down move the focus,
+/// Left collapses, Enter reveals the symbol and closes the picker.
+#[gpui::test]
+fn focus_and_select_shows_the_outline_picker(cx: &mut TestAppContext) {
+ let (workbench, cx, receiver, dir) = open(cx, "breadcrumbs-outline-picker", "class A {\n run() {}\n stop() {}\n}\nclass B {}\n");
+ workbench.update(cx, |workbench, cx| {
+ workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), dir.join("User/keybindings.json"));
+ workbench.language_features.register(crate::workbench::document_symbols::REGISTER, vec![json!(11), json!("*"), json!("Test")]);
+ workbench.language_providers_changed(crate::workbench::document_symbols::REGISTER, cx);
+ });
+ let range = |start: usize, end: usize| json!({ "startLineNumber": start, "startColumn": 1, "endLineNumber": end, "endColumn": 20 });
+ let selection = |line: usize, column: usize| json!({ "startLineNumber": line, "startColumn": column, "endLineNumber": line, "endColumn": column + 1 });
+ answer(&receiver, "$provideDocumentSymbols", json!([
+ { "name": "A", "detail": "", "kind": 4, "range": range(1, 4), "selectionRange": selection(1, 7), "children": [
+ { "name": "run", "detail": "", "kind": 5, "range": range(2, 2), "selectionRange": selection(2, 3), "children": [] },
+ { "name": "stop", "detail": "", "kind": 5, "range": range(3, 3), "selectionRange": selection(3, 3), "children": [] },
+ ] },
+ { "name": "B", "detail": "", "kind": 4, "range": range(5, 5), "selectionRange": selection(5, 7), "children": [] },
+ ]), cx);
+ workbench.update_in(cx, |workbench, window, cx| {
+ workbench.refresh_outline_pane(cx);
+ workbench.reveal_outline_symbol("root/provider_0/A/run", false, window, cx);
+ });
+ cx.run_until_parked();
+ let state = |cx: &mut gpui::VisualTestContext| {
+ workbench.update_in(cx, |workbench, window, _| {
+ let picker = workbench.breadcrumbs.picker.as_ref().map(|picker| {
+ let rows: Vec<String> = workbench.breadcrumbs_picker_rows(picker).into_iter().map(|row| row.key).collect();
+ (picker.item, rows, picker.focused.clone(), picker.focus.is_focused(window))
+ });
+ (picker, workbench.key_context(window)["breadcrumbsActive"] == json!(true), workbench.editors.active().unwrap().selection().head)
+ })
+ };
+ let ids = |names: &[&str]| names.iter().map(|name| format!("root/provider_0/{name}")).collect::<Vec<_>>();
+
+ cx.simulate_keystrokes("cmd-shift-.");
+ let (picker, active, _) = state(cx);
+ assert_eq!(picker, Some((2, ids(&["A", "A/run", "A/stop", "B"]), Some(ids(&["A/run"])[0].clone()), true)), "run's picker, A expanded");
+ assert!(active, "a showing picker keeps breadcrumbsActive");
+
+ cx.simulate_keystrokes("alt-left");
+ assert_eq!(state(cx).0.map(|(item, _, focused, _)| (item, focused)), Some((1, Some(ids(&["A"])[0].clone()))), "focusPreviousWithPicker shows A's picker");
+ cx.simulate_keystrokes("alt-right");
+ assert_eq!(state(cx).0.map(|(item, _, focused, _)| (item, focused)), Some((2, Some(ids(&["A/run"])[0].clone()))), "and focusNextWithPicker run's again");
+
+ cx.simulate_keystrokes("down");
+ assert_eq!(state(cx).0.unwrap().2, Some(ids(&["A/stop"])[0].clone()));
+ cx.simulate_keystrokes("up up left");
+ assert_eq!(state(cx).0.unwrap().1, ids(&["A", "B"]), "Left collapses A");
+ cx.simulate_keystrokes("down enter");
+ assert_eq!(state(cx), (None, false, Position::new(4, 6)), "Enter reveals B and closes the picker");
+}
+
+/// breadcrumbsPicker.ts `BreadcrumbsFilePicker`: a click on the file item lists its folder, folders first, with the
+/// file focused; Escape closes it, and Enter on another file opens it in the group.
+#[gpui::test]
+fn a_click_shows_the_file_picker(cx: &mut TestAppContext) {
+ let (workbench, cx, _receiver, dir) = open(cx, "breadcrumbs-file-picker", "text\n");
+ std::fs::write(dir.join("b.txt"), "b\n").unwrap();
+ std::fs::create_dir_all(dir.join("sub")).unwrap();
+ std::fs::create_dir_all(dir.join(".git")).unwrap();
+ workbench.update(cx, |workbench, _| workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), dir.join("User/keybindings.json")));
+ cx.run_until_parked();
+ let file_item = cx.debug_bounds("breadcrumb-item-0").expect("the file item is drawn").center();
+ cx.simulate_click(file_item, gpui::Modifiers::none());
+ let rows = |cx: &mut gpui::VisualTestContext| {
+ workbench.update_in(cx, |workbench, window, _| {
+ workbench.breadcrumbs.picker.as_ref().map(|picker| {
+ let rows: Vec<String> = workbench.breadcrumbs_picker_rows(picker).into_iter().map(|row| row.key).collect();
+ (rows, picker.focused.clone(), picker.focus.is_focused(window))
+ })
+ })
+ };
+ let path = |name: &str| dir.join(name).to_string_lossy().into_owned();
+ assert_eq!(rows(cx), Some((vec![path("sub"), path("a.txt"), path("b.txt")], Some(path("a.txt")), true)), ".git is a files.exclude default");
+
+ cx.simulate_keystrokes("escape");
+ assert_eq!(rows(cx), None, "Escape closes the picker");
+ let focused = workbench.update_in(cx, |workbench, window, _| workbench.editor_focus.is_focused(window));
+ assert!(focused, "and gives the editor the focus back");
+
+ cx.simulate_click(file_item, gpui::Modifiers::none());
+ cx.simulate_keystrokes("down enter");
+ let (picker, path) = workbench.update(cx, |workbench, _| (workbench.breadcrumbs.picker.is_some(), workbench.editors.active().unwrap().document().path.clone()));
+ assert_eq!((picker, path), (false, dir.join("b.txt")), "Enter opens b.txt and closes the picker");
+
+ cx.simulate_click(file_item, gpui::Modifiers::none());
+ cx.simulate_keystrokes("up cmd-enter");
+ workbench.read_with(cx, |workbench, _| {
+ let groups = workbench.groups_in_grid_order();
+ assert_eq!((groups.len(), workbench.editors.id), (2, groups[1]), "revealFocusedFromTreeAside opens to the side");
+ assert_eq!(workbench.editors.active().unwrap().document().path, dir.join("a.txt"));
+ assert!(workbench.breadcrumbs.picker.is_none());
+ });
+}
+
+/// breadcrumbsControl.ts `toggleToOn` turns the breadcrumbs on and selects the last item; with
+/// `breadcrumbs.useQuickPick` a selection opens Quick Open, `@` for a symbol, instead of a picker.
+#[gpui::test]
+fn toggle_to_on_and_use_quick_pick(cx: &mut TestAppContext) {
+ let (workbench, cx, _receiver, dir) = open(cx, "breadcrumbs-toggle-to-on", "text\n");
+ workbench.update(cx, |workbench, cx| {
+ workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), dir.join("User/keybindings.json"));
+ // useQuickPick has no schema (breadcrumbs.ts `BreadcrumbsConfig`), so only settings.json sets it.
+ std::fs::create_dir_all(dir.join("User")).unwrap();
+ std::fs::write(dir.join("User/settings.json"), r#"{ "breadcrumbs.enabled": false, "breadcrumbs.useQuickPick": true }"#).unwrap();
+ workbench.reload_changed_settings_files(cx);
+ });
+ cx.run_until_parked();
+ cx.simulate_keystrokes("cmd-shift-.");
+ cx.run_until_parked();
+ workbench.update(cx, |workbench, _| {
+ assert_eq!(workbench.setting("breadcrumbs.enabled"), json!(true), "toggleToOn turns the breadcrumbs on");
+ assert!(workbench.breadcrumbs.picker.is_none(), "useQuickPick shows no picker");
+ let value = workbench.quick_inputs.current().map(|input| input.input_box.value.clone());
+ assert_eq!(value, Some(String::new()), "the file item opens Quick Open");
+ });
+}
diff --git a/native/crates/app/src/workbench/editor_view.rs b/native/crates/app/src/workbench/editor_view.rs
index eb09e9c84d3..fbb9e20e4bf 100644
--- a/native/crates/app/src/workbench/editor_view.rs
+++ b/native/crates/app/src/workbench/editor_view.rs
@@ -309,7 +309,7 @@ impl Workbench {
true => self.foreground_or("tab.activeForeground"),
false => self.foreground_or("tab.unfocusedActiveForeground"),
};
- let breadcrumbs = (breadcrumbs && active_group).then(|| self.inline_breadcrumbs(editor));
+ let breadcrumbs = (breadcrumbs && active_group).then(|| self.inline_breadcrumbs(editor, cx));
let description = breadcrumbs.is_none().then(|| self.single_tab_description(tab)).flatten();
let icon = match matches!(tab.document().scheme.as_str(), crate::notebook::NOTEBOOK_EDITOR_SCHEME | super::welcome_page::WALKTHROUGH_SCHEME) {
true => self.document_icon(tab, SINGLE_TAB_TITLE_HEIGHT, foreground),
@@ -822,15 +822,15 @@ impl Workbench {
.flex()
.bg(self.color("breadcrumb.background"))
.text_color(foreground)
- .child(self.breadcrumbs_widget(editor, false))
+ .child(self.breadcrumbs_widget(editor, false, cx))
.children(self.editor_type_picker(cx))
.when_some(title_border, |crumbs, color| crumbs.child(div().absolute().bottom_0().left_0().right_0().h(px(1.)).bg(color)))
}
/// singleeditortabscontrol.css `.title.breadcrumbs`: the breadcrumbs after the single tab's label, .45em after it,
/// `/` between the items in place of the chevrons, ` • ` after a workspace folder, and no file icon.
- fn inline_breadcrumbs(&self, editor: &OpenEditor) -> Div {
- self.breadcrumbs_widget(editor, true).ml(px(13. * 0.45)).h_full().text_color(self.color("breadcrumb.foreground")).when(editor.preview, |crumbs| crumbs.italic())
+ fn inline_breadcrumbs(&self, editor: &OpenEditor, cx: &mut Context<Self>) -> Div {
+ self.breadcrumbs_widget(editor, true, cx).ml(px(13. * 0.45)).h_full().text_color(self.color("breadcrumb.foreground")).when(editor.preview, |crumbs| crumbs.italic())
}
/// A notebook editor's breadcrumbs are its notebook's resource and the notebook outline (notebookOutline.ts).
@@ -867,7 +867,7 @@ impl Workbench {
(segments, is_relative, has_root_folder)
}
- fn breadcrumbs_widget(&self, editor: &OpenEditor, inline: bool) -> Div {
+ fn breadcrumbs_widget(&self, editor: &OpenEditor, inline: bool, cx: &mut Context<Self>) -> Div {
let foreground = self.color("breadcrumb.foreground");
let line_height = if inline { SINGLE_TAB_TITLE_HEIGHT } else { BREADCRUMBS_HEIGHT };
let (notebook_path, notebook_items) = self.notebook_breadcrumbs_of(editor, foreground, line_height).unzip();
@@ -902,22 +902,60 @@ impl Workbench {
// breadcrumbsWidget.css: an item is its icon, its label and the 16px separator codicon, without gaps; the
// first one starts 16px in, measured against the reference with ui-pair.
let focused = self.breadcrumbs_focused();
- // breadcrumbsWidget.ts `_style`: the focused item and a hovered other one in `breadcrumb.focusForeground`.
+ let selected = self.breadcrumbs_selected();
+ // breadcrumbsWidget.ts `_style`: the focused item and a hovered other one in `breadcrumb.focusForeground`, the
+ // focused and selected one in `breadcrumb.activeSelectionForeground`; the separator inherits the item's color.
let focus_foreground = self.color("breadcrumb.focusForeground");
+ let selection_foreground = self.color("breadcrumb.activeSelectionForeground");
+ let group = self.editors.id;
+ let item_bounds = self.breadcrumbs.item_bounds.clone();
let items = file_items.chain(symbol_items).enumerate().map(|(index, (icon, segment))| {
let root_folder = has_root_folder && index == 0;
let slash = !root_folder && !(index == 0 && is_relative) && !(index == 1 && has_root_folder);
let is_focused = focused == Some(index);
- // breadcrumbscontrol.css: the focused item's label is underlined.
- let segment = div().when(is_focused, |label| label.underline()).child(segment);
- let foreground = if is_focused { focus_foreground } else { foreground };
+ let is_selected = selected == Some(index);
+ // breadcrumbscontrol.css: the focused or selected item's label is underlined.
+ let segment = div().when(is_focused || is_selected, |label| label.underline()).child(segment);
+ let foreground = match (is_focused, is_selected) {
+ (true, true) => selection_foreground,
+ (true, false) => focus_foreground,
+ (false, _) => foreground,
+ };
+ let hoverable = !is_focused && !is_selected;
+ let item_bounds = item_bounds.clone();
+ // breadcrumbsWidget.ts `_focus` gives the item DOM focus: workbench.css's 1px `focusBorder` outline.
+ let outline = self.theme.color("focusBorder").filter(|_| is_focused);
+ let widget_focus = self.breadcrumbs.focus.clone();
div()
+ .id(("breadcrumb-item", index))
.debug_selector(move || format!("breadcrumb-item-{index}"))
+ .relative()
+ .group("breadcrumb-item")
+ .child(
+ canvas(
+ move |bounds, _, _| {
+ item_bounds.borrow_mut().insert((group, index), bounds);
+ },
+ move |bounds, _, window, _| {
+ if let Some(outline) = outline.filter(|_| widget_focus.is_focused(window)) {
+ window.paint_quad(gpui::outline(bounds, outline, gpui::BorderStyle::Solid));
+ }
+ },
+ )
+ .absolute()
+ .size_full(),
+ )
+ .on_click(cx.listener(move |workbench, event: &gpui::ClickEvent, window, cx| {
+ if workbench.editors.id != group {
+ workbench.focus_group(group, window, cx);
+ }
+ workbench.breadcrumb_clicked(index, f32::from(event.position().x), window, cx);
+ }))
.flex()
.items_center()
.whitespace_nowrap()
.text_color(foreground)
- .when(!is_focused, |item| item.hover(|item| item.text_color(focus_foreground)))
+ .when(hoverable, |item| item.hover(|item| item.text_color(focus_foreground)))
.map(|item| match inline {
true => item.when(slash, |item| item.child(div().text_size(px(13. * 0.9)).child("/"))),
false => item.when(index == 0, |item| item.pl(px(16.))),
@@ -926,7 +964,7 @@ impl Workbench {
.child(segment)
.map(|item| match inline {
true => item.when(root_folder, |item| item.child(div().text_size(px(13. * 0.9)).child("\u{a0}\u{2022}\u{a0}"))).when(index == last, |item| item.pr(px(4.))),
- false => item.when(index < last, |item| item.child(self.icon("chevron-right", 16., 16., foreground))),
+ false => item.when(index < last, |item| item.child(self.breadcrumb_separator(foreground, hoverable.then_some(focus_foreground)))),
})
});
div()
@@ -944,6 +982,17 @@ impl Workbench {
.child(div().flex_none().min_w_full().flex().children(items))
}
+ /// The chevron after an item, in the item's color, and in `hover_color` while the item is hovered: the svg's
+ /// color is its own, so the hovered one is a second chevron shown over it.
+ fn breadcrumb_separator(&self, color: Rgba, hover_color: Option<Rgba>) -> Div {
+ let chevron = self.icon("chevron-right", 16., 16., color);
+ let Some(hover_color) = hover_color else { return chevron };
+ div()
+ .relative()
+ .child(chevron.group_hover("breadcrumb-item", |chevron| chevron.invisible()))
+ .child(div().absolute().inset_0().invisible().group_hover("breadcrumb-item", |chevron| chevron.visible()).child(self.icon("chevron-right", 16., 16., hover_color)))
+ }
+
pub(super) fn editor_metrics(&self, editor: &OpenEditor, window: &mut Window) -> EditorMetrics {
if self.editors.multi_diff_side(editor.model_id).is_some() {
return self.multi_diff_editor_metrics(editor, window);
diff --git a/native/crates/app/src/workbench/keyboard.rs b/native/crates/app/src/workbench/keyboard.rs
index e94538cd577..183c58a2733 100644
--- a/native/crates/app/src/workbench/keyboard.rs
+++ b/native/crates/app/src/workbench/keyboard.rs
@@ -214,7 +214,7 @@ impl Workbench {
return;
}
// The menu's own key handlers run before the window's keybindings.
- if self.context_menu_key(keystroke, window, cx) || self.custom_dialog_key(keystroke, window, cx) || self.accessible_view_key(keystroke, window, cx) || self.icon_select_box_key(keystroke, window, cx) || self.update_tooltip_key(keystroke, window, cx) {
+ if self.context_menu_key(keystroke, window, cx) || self.custom_dialog_key(keystroke, window, cx) || self.accessible_view_key(keystroke, window, cx) || self.icon_select_box_key(keystroke, window, cx) || self.update_tooltip_key(keystroke, window, cx) || self.breadcrumbs_picker_key(keystroke, window, cx) {
cx.stop_propagation();
return;
}
@@ -500,7 +500,7 @@ impl Workbench {
let breadcrumbs_possible = self.breadcrumbs_possible(editor);
context.insert("breadcrumbsPossible".into(), json!(breadcrumbs_possible));
context.insert("breadcrumbsVisible".into(), json!(self.breadcrumbs_visible(editor)));
- context.insert("breadcrumbsActive".into(), json!(self.breadcrumbs.focus.is_focused(window)));
+ context.insert("breadcrumbsActive".into(), json!(self.breadcrumbs_active(window)));
context.insert("breadcrumbsHasSymbols".into(), json!(breadcrumbs_possible && !self.breadcrumb_symbols(editor).is_empty()));
let pane = match editor.document().scheme.as_str() {
_ if self.playground_active() => "workbench.editor.walkThroughPart",
@@ -603,8 +603,8 @@ impl Workbench {
}
self.open_editors_context(window, &mut context);
self.outline_context(window, &mut context);
- // After the side bar's keys, whose list is not focused: the notebook's cell list is a list (notebookCellList.ts).
- if self.notebook_views.list_focus.is_focused(window) {
+ // After the side bar's keys, whose list is not focused: the notebook's cell list (notebookCellList.ts) and the breadcrumbs picker are lists.
+ if self.notebook_views.list_focus.is_focused(window) || self.breadcrumbs.picker.as_ref().is_some_and(|picker| picker.focus.is_focused(window)) {
context.insert("listFocus".into(), json!(true));
}
self.scm_key_context(window, &mut context);
diff --git a/native/crates/app/src/workbench/outline_pane.rs b/native/crates/app/src/workbench/outline_pane.rs
index 6f8936cc93c..dd1009ae743 100644
--- a/native/crates/app/src/workbench/outline_pane.rs
+++ b/native/crates/app/src/workbench/outline_pane.rs
@@ -63,8 +63,8 @@ impl OutlinePane {
pub(super) struct Row<'a> {
pub(super) depth: usize,
pub(super) id: &'a str,
- group: Option<&'a str>,
- element: Option<&'a OutlineElement>,
+ pub(super) group: Option<&'a str>,
+ pub(super) element: Option<&'a OutlineElement>,
pub(super) has_children: bool,
}
@@ -316,7 +316,7 @@ impl Workbench {
/// `icon_color` overrides the symbol color on a selected row of the focused tree; iconlabel.css shows the detail
/// at full opacity on a focused or selected row.
- fn outline_element_label(&self, element: &OutlineElement, highlights: &[std::ops::Range<usize>], focused_or_selected: bool, icon_color: Option<gpui::Rgba>) -> Div {
+ pub(super) fn outline_element_label(&self, element: &OutlineElement, highlights: &[std::ops::Range<usize>], focused_or_selected: bool, icon_color: Option<gpui::Rgba>) -> Div {
let symbol = &element.symbol;
let codicon = crate::symbol_icons::codicon(symbol.kind);
let icon_color = icon_color.or_else(|| crate::symbol_icons::color_key(codicon).and_then(|key| self.theme.color(key))).unwrap_or(self.color("foreground"));
@@ -656,7 +656,7 @@ fn outline_element_title(element: &OutlineElement) -> String {
format!("{} ({})", element.symbol.name, crate::symbol_icons::kind_name(element.symbol.kind).unwrap_or("undefined"))
}
-fn push_elements<'a>(rows: &mut Vec<Row<'a>>, elements: &'a [OutlineElement], depth: usize, sort_by: SortOrder, expanded: &impl Fn(&str) -> bool, shown: &impl Fn(&OutlineElement) -> bool) {
+pub(super) fn push_elements<'a>(rows: &mut Vec<Row<'a>>, elements: &'a [OutlineElement], depth: usize, sort_by: SortOrder, expanded: &impl Fn(&str) -> bool, shown: &impl Fn(&OutlineElement) -> bool) {
let mut sorted: Vec<&OutlineElement> = elements.iter().filter(|element| shown(element)).collect();
sorted.sort_by(|a, b| compare_elements(a, b, sort_by));
for element in sorted {
diff --git a/native/crates/app/src/workbench/search_actions.rs b/native/crates/app/src/workbench/search_actions.rs
index e337f34d75b..ea6f0850248 100644
--- a/native/crates/app/src/workbench/search_actions.rs
+++ b/native/crates/app/src/workbench/search_actions.rs
@@ -410,7 +410,7 @@ impl Workbench {
for id in super::explorer_keyboard::EXPLORER_LIST_COMMANDS {
let search_run = commands.iter().find(|(search_id, _)| *search_id == id).map(|(_, run)| *run);
self.commands.register(id, move |workbench, _, window, cx| {
- if workbench.keybindings_table_list_command(id, window, cx) || workbench.references_peek_list_command(id, window, cx) || workbench.hierarchy_peek_list_command(id, window, cx) || workbench.debug_hover_list_command(id, window, cx) || workbench.notebook_list_command(id, window, cx) || workbench.multi_diff_file_list_command(id, window, cx) || workbench.scm_repositories_list_command(id, window, cx) {
+ if workbench.breadcrumbs_picker_list_command(id, window, cx) || workbench.keybindings_table_list_command(id, window, cx) || workbench.references_peek_list_command(id, window, cx) || workbench.hierarchy_peek_list_command(id, window, cx) || workbench.debug_hover_list_command(id, window, cx) || workbench.notebook_list_command(id, window, cx) || workbench.multi_diff_file_list_command(id, window, cx) || workbench.scm_repositories_list_command(id, window, cx) {
return Outcome::done();
}
match search_run {
diff --git a/port/fixtures/ui-pair/m8/breadcrumbs-pickers.json b/port/fixtures/ui-pair/m8/breadcrumbs-pickers.json
new file mode 100644
index 00000000000..f4a5e9950de
--- /dev/null
+++ b/port/fixtures/ui-pair/m8/breadcrumbs-pickers.json
@@ -0,0 +1,16 @@
+[
+ {"wait": 8000},
+ {"hotkey": ["cmd", "shift", "."]},
+ {"wait": 1000},
+ {"shot": "outline-picker"},
+ {"hotkey": ["option", "left"]},
+ {"wait": 1000},
+ {"shot": "file-picker"},
+ {"hotkey": ["option", "left"]},
+ {"wait": 1000},
+ {"shot": "folder-picker"},
+ {"key": "escape"},
+ {"hotkey": ["cmd", "shift", ";"]},
+ {"wait": 500},
+ {"shot": "focused"}
+]
diff --git a/port/ledger.md b/port/ledger.md
index f5d860c1162..6d6e884cdb1 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -354,7 +354,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/parts/banner | workbench part | M11 | verified | | workbench/banner.rs (bannerPart.ts): one item by priority, icon, message with ellipsis, link actions, Close Banner; Focus Banner, `bannerFocused`, arrow keys through the links and the close button, Enter and Space on them. `cargo test -p app banner`; verified: ui-pair banner.json vs the reference (port/results/windows.md, milestone 11 verification) |
| workbench/parts/chat | workbench part | | removed | | no sign-in/AI by decision (port/notes.md); not ported |
| workbench/parts/dialogs | workbench part | M11 | verified | | workbench/dialog_view.rs custom dialog, used for every message box with `window.dialogStyle: custom` (severity codicons, plain detail); cargo test -p app dialogs; verified: ui-pair dialogs.json `custom-modal` vs the reference (port/results/windows.md, milestone 11 verification): size, buttons in macOS order, Close Dialog; its buttons and Close Dialog are accessibility buttons named by their labels (dialog.ts monaco Buttons, the close action's aria-label): port/tools/update-check pre-release presses "Trust Publisher & Install" through them |
-| workbench/parts/editor | workbench part | M8 | ported | [3 L] breadcrumbs: no click, file and outline pickers (breadcrumbsPicker.ts; `breadcrumbs.focusAndSelect`, `selectFocused`, `focusNextWithPicker`, `revealFocusedFromTreeAside`, `toggleToOn`, `breadcrumbs.useQuickPick`) | connected tab strip (preview/pinned, close, split and more actions), a dirty tab still open in another group closes without the save prompt (editorGroupView.ts `isOpenedInOtherGroup`: cargo test -p app the_wait_marker_waits_for_the_dirty_file_to_be_saved), breadcrumbs, text editor with gutter, current line, indent guides, word highlight, overview ruler, click, drag and keyboard selection, typing, undo, clipboard, save and dirty tabs (port/notes.md milestone 5): cargo test -p app editor::tests (91), keys_and_typed_text_edit_the_focused_editor_and_reach_the_host; tab context menu (Close, Close Others, Close to the Right, Close Saved, Close All, Keep Open; port/results/contextmenu.md): cargo test -p app editor_menus (8); `_workbench.open` and `vscode.open` (file, untitled with its path, web link, view columns): cargo test -p app workbench_open (3), `_workbench.diff` with the diff editor: cargo test -p app diff_editor; editor groups and splits (split, move, join, focus, tab drag and drop with editorDropTarget.ts split areas): cargo test -p app editor_groups (11), editor_grid (14); locked scrolling (workbench/scroll_locking.rs): cargo test -p app scroll_locking; editorpart.state restored from workspace storage: cargo test -p app the_grid_and_its_editors_come_back_from_workspace_storage; pixel-check file window (port/results/pixels.md milestone 4); all run at the milestone 20 sweep; one group: connected tab strip (preview/pinned, close, split and more actions drawn), breadcrumbs, text editor with gutter, current line, indent guides, word highlight, overview ruler, click, drag and keyboard selection, typing, undo, clipboard, save and dirty tabs (port/notes.md milestone 5); tab context menu with Close, Close Others, Close to the Right, Close Saved, Close All, Keep Open since milestone 9 (port/results/contextmenu.md, cargo test -p app editor_menus); `_workbench.open` and `vscode.open` open a file, an untitled file with its path or a web link (cargo test -p app workbench_open, port/results/api-tests.md M12 `_workbench.open`), every view column in the one group; no `_workbench.diff` (diff editor); editor groups and splits since milestone 11 (split, move, join, focus, tab drag and drop with editorDropTarget.ts split areas; cargo test -p app editor_groups, editor_grid); no scrolling sync; minimap since milestone 8; cargo test -p app (editor::tests, workbench keys_and_typed_text_edit_the_focused_editor_and_reach_the_host); pixel-check file window (port/results/pixels.md milestone 4, unchanged at milestone 5); editorpart.state: the grid and the groups' file editors restored from workspace storage (cargo test -p app the_grid_and_its_editors_come_back_from_workspace_storage); one group: connected tab strip (preview/pinned, close, split and more actions drawn), breadcrumbs, text editor with gutter, current line, indent guides, word highlight, overview ruler, click, drag and keyboard selection, typing, undo, clipboard, save and dirty tabs (port/notes.md milestone 5); tab context menu with Close, Close Others, Close to the Right, Close Saved, Close All, Keep Open since milestone 9 (port/results/contextmenu.md, cargo test -p app editor_menus); `_workbench.open` and `vscode.open` open a file, an untitled file with its path or a web link (cargo test -p app workbench_open, port/results/api-tests.md M12 `_workbench.open`), every view column in the one group; no `_workbench.diff` (diff editor); editor groups and splits since milestone 11 (split, move, join, focus, tab drag and drop with editorDropTarget.ts split areas; cargo test -p app editor_groups, editor_grid); no scrolling sync; minimap since milestone 8; cargo test -p app (editor::tests, workbench keys_and_typed_text_edit_the_focused_editor_and_reach_the_host); pixel-check file window (port/results/pixels.md milestone 4, unchanged at milestone 5); breadcrumbs editor type picker (editor_type_picker.rs, editorTypePicker.ts) for text and diff editors: Text Diff Editor label, `priority.diffEditor` ranks, `workbench.diffEditorAssociations`, Set Default (Diff Only), Open Original/Modified: cargo test -p app editor_type_picker; ui-pair m12/editor-type.json matches, the menus' width included; the editor title's ... menu (MenuId.EditorTitle with Reopen Editor With, the button's `toolbar.activeBackground` while it shows), the empty group context menu (MenuId.EmptyEditorGroupContext) and the watermark shortcuts: ui-pair m11/editor-menus.json and m11/watermark-tips.json (port/results/auxiliary-windows.md), cargo test -p app editor_menus editor_type_picker; the empty group menu's New Terminal; the Text Editor control at a second start, restored from the `memento/customEditors` profile memento as contributedCustomEditors.ts does (cargo test -p app editor_type_picker custom_editors, ui-pair m12/editor-type-second-start.json); terminal editors (terminalEditorService.ts, terminalEditorInput.ts): Create New Terminal in Editor Area, Move Terminal into Editor Area and into the Panel, the terminal tab's context and title menus, `TabInputKind.TerminalEditorInput` tabs (cargo test -p app terminal_editor, ui-pair m12/terminal-editor.json); terminal editors restored after a restart (terminalEditorSerializer.ts); the terminal tab menus' Change Color, Change Icon, Toggle Size to Content Width and Move Terminal into New Window with the color and icon pickers (cargo test -p app terminal_editor icon_select_box, ui-pair m12/terminal-pickers.json and m12/terminal-tab-list-menu.json, m12/editor-type-second-start.json); `workbench.editor.enablePreview` off opens every editor pinned and Toggle Keep Editors pins the preview editor (cargo test -p app previews_off_pins_every_opened_editor); tab labels keep fractional text widths (vendored GPUI elements/text.rs; cargo test -p app tab_labels_keep, ui-pair icons/seti.json); `workbench.editor.showTabs` per part (editorTitleControl.ts): `single` draws singleEditorTabsControl.ts, the active editor's label 35px high, its breadcrumbs inline with `/` while the group is active, else its `workbench.editor.labelFormat` description, the close or unpin action, the actions at half opacity in an inactive group, `none` only the breadcrumbs row, `editorTabsVisible` (workbench/editor_view.rs `single_editor_tab_title`; cargo test -p app show_tabs_picks_the_title_control_and_zen_mode_enforces_its_own; ui-pair `show-tabs.json` with SETTINGS single and none). `workbench.editor.editorActionsLocation` (titlebarPart.ts `editorActionsEnabled`): `titleBar`, or `default` with `showTabs: none`, draws the editor actions in the title bar before the layout controls with their overflow, Customize Layout moves into it (layoutActions.ts `EditorActionsInTitleBar`), the command center names the active file with its dirty dot, `hidden` draws them nowhere, and titlebarActions.ts `ToggleEditorActions` keeps the hidden location in profile storage; the six Show/Hide Editor Tabs commands (layoutActions.ts `AbstractSetShowTabsAction`) and the Editor Actions Position setters with their Tab Bar and Editor Actions Position submenus in View > Appearance and the tab bar's `EditorTabsBarContext` menu (workbench/editor_view.rs `title_bar_has_editor_actions`, workbench/editor_menus.rs `show_tabs_bar_context_menu`; cargo test -p app show_tabs_none_moves_the_editor_actions_into_the_title_bar the_tab_bar_menu_switches_the_tabs_mode the_editor_actions_toggle_restores_the_hidden_location menubar; ui-pair `show-tabs.json` with SETTINGS none: the title bar's split, close, separator, layout controls and `...` and the command center's main.ts match the reference); breadcrumbs focus mode (workbench/breadcrumbs.rs, breadcrumbsControl.ts): Focus Breadcrumbs focuses the last item, Left and Right move the focus, Space and Cmd+Enter reveal the focused file or symbol, Escape focuses the editor, the focused item underlined in `breadcrumb.focusForeground`, `breadcrumbsActive`: cargo test -p app the_keyboard_focuses_moves_through_and_reveals_the_breadcrumbs |
+| workbench/parts/editor | workbench part | M8 | ported | [3 M] breadcrumbs pickers against ui-pair port/fixtures/ui-pair/m8/breadcrumbs-pickers.json (`FILE=src/main.ts`): in the GUI Alt+Left from a picker hides it where the reference shows the previous item's (the test passes); the picker has no arrow, sits 4 px high, its symbol icons take the symbol colors (the reference's are the foreground) and its focused row is square; the focused last item's outline is 8 px narrower | breadcrumbs click, file and outline pickers, `focusAndSelect`, `selectFocused`, `focusNext/PreviousWithPicker`, `revealFocusedFromTreeAside`, `toggleToOn` and `breadcrumbs.useQuickPick` (breadcrumbsControl.ts, breadcrumbsPicker.ts: cargo test -p app workbench::breadcrumbs), connected tab strip (preview/pinned, close, split and more actions), a dirty tab still open in another group closes without the save prompt (editorGroupView.ts `isOpenedInOtherGroup`: cargo test -p app the_wait_marker_waits_for_the_dirty_file_to_be_saved), breadcrumbs, text editor with gutter, current line, indent guides, word highlight, overview ruler, click, drag and keyboard selection, typing, undo, clipboard, save and dirty tabs (port/notes.md milestone 5): cargo test -p app editor::tests (91), keys_and_typed_text_edit_the_focused_editor_and_reach_the_host; tab context menu (Close, Close Others, Close to the Right, Close Saved, Close All, Keep Open; port/results/contextmenu.md): cargo test -p app editor_menus (8); `_workbench.open` and `vscode.open` (file, untitled with its path, web link, view columns): cargo test -p app workbench_open (3), `_workbench.diff` with the diff editor: cargo test -p app diff_editor; editor groups and splits (split, move, join, focus, tab drag and drop with editorDropTarget.ts split areas): cargo test -p app editor_groups (11), editor_grid (14); locked scrolling (workbench/scroll_locking.rs): cargo test -p app scroll_locking; editorpart.state restored from workspace storage: cargo test -p app the_grid_and_its_editors_come_back_from_workspace_storage; pixel-check file window (port/results/pixels.md milestone 4); all run at the milestone 20 sweep; one group: connected tab strip (preview/pinned, close, split and more actions drawn), breadcrumbs, text editor with gutter, current line, indent guides, word highlight, overview ruler, click, drag and keyboard selection, typing, undo, clipboard, save and dirty tabs (port/notes.md milestone 5); tab context menu with Close, Close Others, Close to the Right, Close Saved, Close All, Keep Open since milestone 9 (port/results/contextmenu.md, cargo test -p app editor_menus); `_workbench.open` and `vscode.open` open a file, an untitled file with its path or a web link (cargo test -p app workbench_open, port/results/api-tests.md M12 `_workbench.open`), every view column in the one group; no `_workbench.diff` (diff editor); editor groups and splits since milestone 11 (split, move, join, focus, tab drag and drop with editorDropTarget.ts split areas; cargo test -p app editor_groups, editor_grid); no scrolling sync; minimap since milestone 8; cargo test -p app (editor::tests, workbench keys_and_typed_text_edit_the_focused_editor_and_reach_the_host); pixel-check file window (port/results/pixels.md milestone 4, unchanged at milestone 5); editorpart.state: the grid and the groups' file editors restored from workspace storage (cargo test -p app the_grid_and_its_editors_come_back_from_workspace_storage); one group: connected tab strip (preview/pinned, close, split and more actions drawn), breadcrumbs, text editor with gutter, current line, indent guides, word highlight, overview ruler, click, drag and keyboard selection, typing, undo, clipboard, save and dirty tabs (port/notes.md milestone 5); tab context menu with Close, Close Others, Close to the Right, Close Saved, Close All, Keep Open since milestone 9 (port/results/contextmenu.md, cargo test -p app editor_menus); `_workbench.open` and `vscode.open` open a file, an untitled file with its path or a web link (cargo test -p app workbench_open, port/results/api-tests.md M12 `_workbench.open`), every view column in the one group; no `_workbench.diff` (diff editor); editor groups and splits since milestone 11 (split, move, join, focus, tab drag and drop with editorDropTarget.ts split areas; cargo test -p app editor_groups, editor_grid); no scrolling sync; minimap since milestone 8; cargo test -p app (editor::tests, workbench keys_and_typed_text_edit_the_focused_editor_and_reach_the_host); pixel-check file window (port/results/pixels.md milestone 4, unchanged at milestone 5); breadcrumbs editor type picker (editor_type_picker.rs, editorTypePicker.ts) for text and diff editors: Text Diff Editor label, `priority.diffEditor` ranks, `workbench.diffEditorAssociations`, Set Default (Diff Only), Open Original/Modified: cargo test -p app editor_type_picker; ui-pair m12/editor-type.json matches, the menus' width included; the editor title's ... menu (MenuId.EditorTitle with Reopen Editor With, the button's `toolbar.activeBackground` while it shows), the empty group context menu (MenuId.EmptyEditorGroupContext) and the watermark shortcuts: ui-pair m11/editor-menus.json and m11/watermark-tips.json (port/results/auxiliary-windows.md), cargo test -p app editor_menus editor_type_picker; the empty group menu's New Terminal; the Text Editor control at a second start, restored from the `memento/customEditors` profile memento as contributedCustomEditors.ts does (cargo test -p app editor_type_picker custom_editors, ui-pair m12/editor-type-second-start.json); terminal editors (terminalEditorService.ts, terminalEditorInput.ts): Create New Terminal in Editor Area, Move Terminal into Editor Area and into the Panel, the terminal tab's context and title menus, `TabInputKind.TerminalEditorInput` tabs (cargo test -p app terminal_editor, ui-pair m12/terminal-editor.json); terminal editors restored after a restart (terminalEditorSerializer.ts); the terminal tab menus' Change Color, Change Icon, Toggle Size to Content Width and Move Terminal into New Window with the color and icon pickers (cargo test -p app terminal_editor icon_select_box, ui-pair m12/terminal-pickers.json and m12/terminal-tab-list-menu.json, m12/editor-type-second-start.json); `workbench.editor.enablePreview` off opens every editor pinned and Toggle Keep Editors pins the preview editor (cargo test -p app previews_off_pins_every_opened_editor); tab labels keep fractional text widths (vendored GPUI elements/text.rs; cargo test -p app tab_labels_keep, ui-pair icons/seti.json); `workbench.editor.showTabs` per part (editorTitleControl.ts): `single` draws singleEditorTabsControl.ts, the active editor's label 35px high, its breadcrumbs inline with `/` while the group is active, else its `workbench.editor.labelFormat` description, the close or unpin action, the actions at half opacity in an inactive group, `none` only the breadcrumbs row, `editorTabsVisible` (workbench/editor_view.rs `single_editor_tab_title`; cargo test -p app show_tabs_picks_the_title_control_and_zen_mode_enforces_its_own; ui-pair `show-tabs.json` with SETTINGS single and none). `workbench.editor.editorActionsLocation` (titlebarPart.ts `editorActionsEnabled`): `titleBar`, or `default` with `showTabs: none`, draws the editor actions in the title bar before the layout controls with their overflow, Customize Layout moves into it (layoutActions.ts `EditorActionsInTitleBar`), the command center names the active file with its dirty dot, `hidden` draws them nowhere, and titlebarActions.ts `ToggleEditorActions` keeps the hidden location in profile storage; the six Show/Hide Editor Tabs commands (layoutActions.ts `AbstractSetShowTabsAction`) and the Editor Actions Position setters with their Tab Bar and Editor Actions Position submenus in View > Appearance and the tab bar's `EditorTabsBarContext` menu (workbench/editor_view.rs `title_bar_has_editor_actions`, workbench/editor_menus.rs `show_tabs_bar_context_menu`; cargo test -p app show_tabs_none_moves_the_editor_actions_into_the_title_bar the_tab_bar_menu_switches_the_tabs_mode the_editor_actions_toggle_restores_the_hidden_location menubar; ui-pair `show-tabs.json` with SETTINGS none: the title bar's split, close, separator, layout controls and `...` and the command center's main.ts match the reference); breadcrumbs focus mode (workbench/breadcrumbs.rs, breadcrumbsControl.ts): Focus Breadcrumbs focuses the last item, Left and Right move the focus, Space and Cmd+Enter reveal the focused file or symbol, Escape focuses the editor, the focused item underlined in `breadcrumb.focusForeground`, `breadcrumbsActive`: cargo test -p app the_keyboard_focuses_moves_through_and_reveals_the_breadcrumbs |
| workbench/parts/notifications | workbench part | M11 | verified | | workbench/notifications_view.rs: toasts (3 at most, purge 10/12/15s unless sticky, focused or hovered, spam protection), notifications center (Clear All, Do Not Disturb menu with per-source filters, Hide), rows with expand, collapse, clear, More Actions, buttons, links, Copy Text, double-click toggle; status bar bell states and tooltips; notificationsCommands.ts commands and context keys; geometry from the reference DOM (port/tools/ref-dom); cargo test -p app notifications_view; `workbench.notifications.position` (bottom right, bottom left, top right with the title bar bell); no toast animation, no screen reader announcements; verified: ui-pair messages.json `center`, `progress` vs the reference (port/results/windows.md, milestone 11 verification) |
| workbench/parts/panel | workbench part | M11 | verified | | bottom centered card, view tabs from register_panel_view with the "..." overflow of compositeBar.ts (cargo test -p app workbench::panel::, ui-pair port/results/problems.md), `<view id>.focus` per view, Maximize/Restore, Close, Cmd+J, active view in workspace storage; Problems, Output, Debug Console, Test Results (`hideIfEmpty`) and Terminal views with their title actions (cargo test -p app editor_groups the_output_view_shows_in_the_panel, output_view, the_debug_console_and_test_results_are_panel_views, terminal); part_grid tests, ui-pair port/results/layout.md; no panel position or alignment change, no Views and More Actions menu; verified: ui-pair port/results/problems.md (milestone 11 verification): tabs, "..." overflow and the filter box as the reference; tabs at Chromium's fractional text widths (the Problems tab with its badge was 2px wider: GPUI rounds a text element's width up), the filter in the view below 600px of width (`shouldShowFilterInHeader`) |
| workbench/parts/partGrid | workbench part | M11 | verified | | workbench/layout.rs grid on split_view.rs (splitview.ts priorities, snap, visibility), workbench/part_grid.rs sashes, hidden parts, sizes and visibility in LayoutStateModel storage keys: cargo test -p app layout part_grid split_view (reference geometry at 1024x768, Cmd+B for the next open, sash drag, snap); ui-pair grid steps, port/results/layout.md |
diff --git a/port/notes.md b/port/notes.md
index e0ee313bc60..8e336a13be7 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -488,7 +488,7 @@ Done when (first item): api-tests `vscode API - editors` passes as in the refere
- Word highlights after a picked command: upstream's quick input `hide` focuses the editor before `accept` runs the command, so the command's edit cancels the query `onDidFocusEditorText` started. GPUI reports the restored focus on the next frame, after the command; `watch_editor_focus` skips the query when the model's version changed since the editor lost the focus. Test: `cargo test -p app the_word_highlight_stops`.
- Keystrokes: GPUI reports Shift with a US symbol key as the shifted symbol without Shift (Cmd+Shift+. arrives as Cmd+>); `Chord::from_keystroke` maps it back to the key code and Shift, as upstream's `KeyboardEvent.code` does, so Shift+Cmd+. and Shift+Cmd+, resolve. Test: `cargo test -p app a_shifted_symbol_keystroke`.
- Expand Line Selection (Cmd+L, `CursorMoveCommands.expandLineSelection`): `OpenEditor::expand_line_selection` after an undo stop. Test: `cargo test -p app expand_line_selection`.
-- Replace with Previous/Next Value (`editor/in_place_replace.rs`, inPlaceReplace.ts, `BasicInplaceReplace`): a caret takes the word at it (`DEFAULT_WORD_REGEXP`), a selection its text; numbers step their last digit, value sets (`true`/`false`, the access modifiers, ...) wrap; the selection becomes the new value. The 2px `editorBracketMatch.border` outline (`.monaco-editor.vs .valueSetReplacement`) shows 350 ms in light themes. Shift+Cmd+. resolves to `breadcrumbs.focusAndSelect` in the reference (the later default binding); the port has no breadcrumbs picker, so its `breadcrumbsPossible` is unset and the key runs Next Value. ui-pair (light theme, palette): the values and selections match the reference; the outline was not caught in the shots of either side. Test: `cargo test -p app editor::in_place_replace`.
+- Replace with Previous/Next Value (`editor/in_place_replace.rs`, inPlaceReplace.ts, `BasicInplaceReplace`): a caret takes the word at it (`DEFAULT_WORD_REGEXP`), a selection its text; numbers step their last digit, value sets (`true`/`false`, the access modifiers, ...) wrap; the selection becomes the new value. The 2px `editorBracketMatch.border` outline (`.monaco-editor.vs .valueSetReplacement`) shows 350 ms in light themes. Shift+Cmd+. resolves to `breadcrumbs.focusAndSelect` in the reference and the port (the later default binding, while `breadcrumbsPossible && breadcrumbsVisible`); with breadcrumbs off it is `breadcrumbs.toggleToOn`; only with breadcrumbs on but not possible (an untitled file) does the key run Next Value. ui-pair (light theme, palette): the values and selections match the reference; the outline was not caught in the shots of either side. Test: `cargo test -p app editor::in_place_replace`.
- Rounded selections (`editor.roundedSelection`, selections.ts `_enrichVisibleRangesWithStyle` and selections.css): each line's piece gets external, internal or flat corners from the lines above and below (`selection_corners`, `cargo test -p app selection_corners`), radius 3 px, square in high contrast; internal corners are 10 px pieces painted first in the editor background (issue #77777); with more than one selection each line insets 1 px top and bottom. Upstream keeps the previous frame's corners at the viewport edges; the port reads the lines past the edge. ui-pair (`FILE=notes.txt`, word and multi-line selections, dark): the corners match at 300% (AE 64 over the crop, 0.0005). The reference also draws the selected whitespace (`editor.renderWhitespace: selection`), see the next entry.
- Unicode highlighter (`editor/unicode_highlighter.rs`, `workbench/unicode_highlight.rs`; unicodeHighlighter.ts, unicodeTextModelHighlighter.ts, bannerController.ts): ambiguous, invisible and non-basic ASCII characters get the `editorUnicodeHighlight.border` box, comments and strings by `includeComments`/`includeStrings` (`inUntrustedWorkspace` resolves as trusted: the port has no workspace trust), `allowedCharacters` and `allowedLocales` (`_os` and `_vscode` are English). The confusables and invisibles come from strings.ts as `unicode_data.json`. Past 1000 characters the marks go and a banner names the most frequent reason with its Disable action (sets the `editor.unicodeHighlight.*` user setting); closing it holds until the editor shows another model. New theme defaults: `editorWarning.foreground`, `editorInfo.foreground`, the two `editorUnicodeHighlight.*` and `banner.*` (with `darken`, checked against upstream's color.ts output). Highlights are found on the UI thread per model version, where upstream asks the editor worker (`shortcut:` in the code). The hover reason and its exclude options came with the editor hover (`unicode_hover_reason`, `unicode_exclude_options`). ui-pair (`uni.ts`, `many.ts`): marks and banner match the reference. Tests: `cargo test -p app unicode_highlighter`, `cargo test -p app theme::`.
- Unusual line terminators (`editor/unusual_line_terminators.rs`, `workbench/unusual_line_terminators.rs`; unusualLineTerminators.ts): when the editor shows a model, its content changes (not by undo) or `editor.unusualLineTerminators` changes, LS and PS are removed (`auto`), after the "Detected unusual line terminators" dialog (`prompt`), or left (`off`); Ignore holds for the resource. Test: `cargo test -p app unusual_line_terminators`.