Skip to content

Visual Studio Code, rebuilt in Rust

Rust

fix(mergeEditor): close the title, block, breadcrumb and diff gaps

rokartur716ac8f26361
diff --git a/native/crates/app/src/merge_editor.rs b/native/crates/app/src/merge_editor.rs
index 11fe609e269..82808b657b9 100644
--- a/native/crates/app/src/merge_editor.rs
+++ b/native/crates/app/src/merge_editor.rs
@@ -505,7 +505,7 @@ impl MergeModel {
/// utils.ts `join` of the ranges and the result diffs touching them: result diffs before a range form a row of
/// their own; those after the last range are left out, as upstream.
- fn join_result_diffs(&self) -> Vec<(Option<usize>, Vec<&LineRangeMapping>)> {
+ pub fn join_result_diffs(&self) -> Vec<(Option<usize>, Vec<&LineRangeMapping>)> {
let mut rows = Vec::new();
let mut diffs = self.result_diffs.iter().peekable();
for (index, range) in self.ranges.iter().enumerate() {
diff --git a/native/crates/app/src/workbench/editor_view.rs b/native/crates/app/src/workbench/editor_view.rs
index b92c8821458..be211a6aea5 100644
--- a/native/crates/app/src/workbench/editor_view.rs
+++ b/native/crates/app/src/workbench/editor_view.rs
@@ -147,7 +147,7 @@ impl Workbench {
}
/// breadcrumbsControl.ts `update`: no breadcrumbs for a resource without a file system provider (untitled, a
- /// terminal), nor for the merge editor, nor where another editor draws its own row (search editor, output).
+ /// terminal), nor where another editor draws its own row (search editor, output).
fn editor_has_breadcrumbs(&self, editor: &OpenEditor) -> bool {
let document = editor.document();
let scheme = document.scheme.as_str();
@@ -156,7 +156,6 @@ impl Workbench {
&& !self.active_notebook_resource().is_some_and(|(scheme, _)| scheme == "untitled")
&& !matches!(scheme, super::extension_editor::EXTENSION_EDITOR_SCHEME | super::welcome_page::WALKTHROUGH_SCHEME | SEARCH_EDITOR_SCHEME | crate::output::OUTPUT_SCHEME | "untitled" | TERMINAL_EDITOR_SCHEME)
&& self.editors.active_multi_diff().is_none()
- && self.editors.active_merge().is_none()
}
/// The active tab reaches into the part's top border, which Chrome still draws over it. A compact editor paints
@@ -2854,10 +2853,14 @@ impl Workbench {
/// `getCodeEditor(editorService.activeTextEditorControl)`, which the status bar and breadcrumbs follow: a diff
/// editor's modified side, also while its original side has the focus.
fn active_text_editor_control(&self) -> Option<&OpenEditor> {
- match self.editors.active_diff().and_then(|diff| diff.modified_editor.as_ref()) {
- Some(modified) => Some(modified),
- None => self.editors.pane_editor(),
+ if let Some(modified) = self.editors.active_diff().and_then(|diff| diff.modified_editor.as_ref()) {
+ return Some(modified);
}
+ // mergeEditor.ts `getControl`: the result's editor, also while an input has the focus.
+ if self.editors.active_merge().is_some() {
+ return self.merge_result();
+ }
+ self.editors.pane_editor()
}
/// editorStatus.ts entries of the editor: text, tooltip, command and status bar id.
diff --git a/native/crates/app/src/workbench/editor_view/merge_editor_view.rs b/native/crates/app/src/workbench/editor_view/merge_editor_view.rs
index e57eee89b2b..89e09b80954 100644
--- a/native/crates/app/src/workbench/editor_view/merge_editor_view.rs
+++ b/native/crates/app/src/workbench/editor_view/merge_editor_view.rs
@@ -2,8 +2,6 @@
//! and commands/commands.ts): input 1 and input 2 as read-only code editors beside each other, the result model in
//! the group's code editor, and base on request, in the mixed or the column layout; an action row above each modified base range,
//! accept checkboxes in the inputs' gutters and spacers that line the panes up.
-// shortcut: the result shows no base-to-result diff backgrounds and base no "Comparing with" highlights: the group's
-// code editor takes no merge decorations yet. Add them with a decoration provider hook in the text area.
use std::path::Path;
@@ -25,8 +23,10 @@ use crate::workbench::hover::{HoverContent, HoverOptions};
/// mergeEditor.css `.code-view > .title` height.
const TITLE_HEIGHT: f32 = 24.;
+/// mergeEditor.css `.code-view > .container > .gutter`.
+const GUTTER_WIDTH: f32 = 24.;
/// mergeEditor.css `.merge-accept-gutter-marker`: 28px wide with a 4px left margin.
-const GUTTER_WIDTH: f32 = 32.;
+const MARKER_WIDTH: f32 = 32.;
/// viewZones.ts `Placeholder` height in base.
const PLACEHOLDER_HEIGHT: f32 = 16.;
@@ -469,7 +469,7 @@ impl Workbench {
}
/// The active merge editor's result code editor, whichever of its code editors has the focus.
- fn merge_result(&self) -> Option<&OpenEditor> {
+ pub(super) fn merge_result(&self) -> Option<&OpenEditor> {
let result = &self.editors.active_merge()?.result;
self.editors.model(&result.scheme, &result.path)
}
@@ -856,8 +856,8 @@ impl Workbench {
.overflow_hidden()
.whitespace_nowrap()
.text_size(px(13.))
- .child(label(title, foreground))
- .children(description.map(|description| label(description, dim)))
+ .child(label(title, foreground).flex_none())
+ .children(description.map(|description| label(description, dim).flex_none()))
.children(detail.map(|detail| label(detail, dim)))
}
@@ -866,21 +866,28 @@ impl Workbench {
fn merge_result_title(&self, merge: &MergeInput, result: &OpenEditor, cx: &mut Context<Self>) -> Div {
let count = merge.model.as_ref().map_or(0, MergeModel::unhandled_count);
let counter = if count == 1 { "1 Conflict Remaining".to_string() } else { format!("{count} Conflicts Remaining") };
- let path = crate::quick_input::path_label(&result.document().path, None);
- self.merge_title("Result", Some(&path), None)
+ let path = self.merge_result_path(result);
+ // mergeEditor.css `.code-view.result > .header > .description`: the path alone shrinks, cut with an ellipsis.
+ let path = div().debug_selector(|| "merge-result-path".into()).min_w_0().overflow_hidden().text_ellipsis().text_color(self.color("descriptionForeground")).child(path);
+ self.merge_title("Result", None, None)
+ .child(path)
.child(
div()
.id("merge-counter")
+ .debug_selector(|| "merge-counter".into())
+ .flex_none()
.ml_auto()
.text_color(self.color("descriptionForeground"))
.when(count > 0, |counter| counter.cursor_pointer().on_click(cx.listener(|workbench, _, _, cx| workbench.go_to_unhandled_conflict(true, cx))))
.child(counter),
)
// `MergeInputResultToolbar`: Reset.
- .child(self.merge_toolbar_button("mergeEditor.resetResultToBaseAndAutoMerge", "discard", "Reset Result", cx))
+ .child(self.merge_toolbar_button("mergeEditor.resetResultToBaseAndAutoMerge", "discard", "Reset Result", cx).flex_none())
.child(
div()
.id("merge-complete")
+ .debug_selector(|| "merge-complete".into())
+ .flex_none()
.cursor_pointer()
.px(px(8.))
.rounded(px(2.))
@@ -891,6 +898,11 @@ impl Workbench {
)
}
+ /// resultCodeEditorView.ts `getUriLabel(resultUri, { relative: true })`.
+ fn merge_result_path(&self, result: &OpenEditor) -> String {
+ crate::quick_input::path_label(&result.document().path, self.workspace())
+ }
+
/// The result's code editor with each range's action row and spacer fill in its view zones and its block border.
fn merge_result_area(&self, merge: &MergeInput, result: &OpenEditor, window: &mut Window, cx: &mut Context<Self>) -> Div {
let area = div().flex_1().min_h_0().relative().flex().flex_col().children(self.code_editor_area(result, window, cx));
@@ -922,8 +934,9 @@ impl Workbench {
let blocks: Vec<(usize, LineRange, bool)> = (0..model.ranges.len()).filter(|&index| model.shows_actions(index, show_non_conflicting)).map(|index| (index, model.ranges[index].range(input), handled(index))).collect();
let viewport = self.merge_viewport(editor);
let active = self.active_merge_range();
- let mut gutter = div().w(px(GUTTER_WIDTH)).flex_none().relative().overflow_hidden().bg(self.color("editor.background"));
- for &(index, lines, handled) in blocks.iter().filter(|(index, _, _)| !model.ranges[*index].diffs(input).is_empty()) {
+ let mut gutter = div().debug_selector(move || format!("merge-input{}-gutter", input as usize + 1)).w(px(GUTTER_WIDTH)).flex_none().relative().overflow_hidden().bg(self.color("editor.background"));
+ let checkboxes_visible = self.setting("mergeEditor.showCheckboxes") == json!(true);
+ for &(index, lines, handled) in blocks.iter().filter(|(index, _, _)| checkboxes_visible && !model.ranges[*index].diffs(input).is_empty()) {
let (top, height) = merge_block_span(editor, viewport, lines);
gutter = gutter.child(self.merge_checkbox(model, index, input, lines, handled, active == Some(index), height, cx).absolute().left_0().top(px(top)));
}
@@ -944,7 +957,7 @@ impl Workbench {
let below: f32 = placed[position..].iter().filter(|(_, other)| other.after_line == zone.after_line).map(|(_, other)| self.merge_zone_height(other.kind)).sum();
let zone_top = editor.line_top(editor.view_line(zone.after_line), viewport) - editor.scroll.top - below;
let element = match zone.kind {
- ZoneKind::Actions(index) => self.merge_action_row((id, index), actions(index), cx),
+ ZoneKind::Actions(index) => self.merge_action_row((id, index), actions(index), cx).debug_selector(move || format!("{id}-row-{index}")),
ZoneKind::Spacer(_) | ZoneKind::Placeholder => div().relative().children(fill.map(|fill| diagonal_fill(fill).absolute().inset_0())),
};
overlays.push(element.absolute().left(px(content_left)).right_0().top(px(zone_top)).h(px(self.merge_zone_height(zone.kind))));
@@ -952,25 +965,52 @@ impl Workbench {
let active = self.active_merge_range();
for &(index, lines, handled) in blocks {
let (top, height) = merge_block_span(editor, viewport, lines);
- overlays.push(self.merge_block(handled, active == Some(index)).left(px(content_left)).right_0().top(px(top)).h(px(height)));
+ overlays.push(self.merge_block(handled, active == Some(index)).debug_selector(move || format!("{id}-block-{index}")).left(px(content_left)).right_0().top(px(top)).h(px(height)));
}
overlays
}
- /// inputCodeEditorView.ts `decorations` of a merge editor's input: `merge-editor-diff`
- /// (`mergeEditor.change.background`) on the changed lines of the shown ranges, `merge-editor-diff-word` on their
- /// changed characters.
+ /// inputCodeEditorView.ts and resultCodeEditorView.ts `decorations`: `merge-editor-diff`
+ /// (`mergeEditor.change.background`) on the changed lines, `merge-editor-diff-word` on their changed characters. An
+ /// input shows the diffs of its shown ranges, the result its base-to-result diffs outside a range or touching a
+ /// conflicting one.
pub(super) fn merge_line_decorations(&self, editor: &OpenEditor, index: usize, char_width: f32, scroll_left: f32) -> Vec<Div> {
let Some(merge) = self.editors.active_merge() else { return Vec::new() };
+ let Some(model) = merge.model.as_ref() else { return Vec::new() };
+ let line_number = index + 1;
let shows = |input: &Input| merge.input_editors[*input as usize].as_ref().is_some_and(|shown| shown.model_id == editor.model_id);
- let (Some(input), Some(model)) = ([Input::One, Input::Two].into_iter().find(shows), merge.model.as_ref()) else { return Vec::new() };
+ let change = if let Some(input) = [Input::One, Input::Two].into_iter().find(shows) {
+ let shown = model.ranges.iter().enumerate().filter(|(index, range)| range.is_conflicting() || !model.is_handled(*index));
+ shown.flat_map(|(_, range)| range.diffs(input)).find(|diff| diff.modified.contains(line_number))
+ } else if self.merge_result().is_some_and(|result| result.model_id == editor.model_id) {
+ let rows = model.join_result_diffs().into_iter().filter(|(range, _)| range.is_none_or(|index| model.ranges[index].is_conflicting()));
+ rows.flat_map(|(_, diffs)| diffs).find(|diff| diff.modified.contains(line_number))
+ } else {
+ None
+ };
+ let Some(change) = change else { return Vec::new() };
+ self.merge_change_decorations(change, ZoneSide::Modified, &editor.document().lines[index], editor.document().indentation.tab_size, line_number, char_width, scroll_left)
+ }
+
+ /// baseCodeEditorView.ts `decorations`: while an input was focused last (`baseShowDiffAgainst`), base's lines and
+ /// characters that input changes, in `merge-editor-diff base` and `merge-editor-diff-word base`. mergeEditor.css's
+ /// `.monaco-workbench .merge-editor .merge-editor-diff` outranks `.merge-editor-diff.base`: the colors are the inputs'.
+ fn merge_base_decorations(&self, editor: &OpenEditor, index: usize, char_width: f32) -> Vec<Div> {
+ let Some(merge) = self.editors.active_merge() else { return Vec::new() };
+ let (Some(input), Some(model)) = (merge.focused_input, merge.model.as_ref()) else { return Vec::new() };
+ let show_non_conflicting = self.merge_show_non_conflicting();
let line_number = index + 1;
- let shown = model.ranges.iter().enumerate().filter(|(index, range)| range.is_conflicting() || !model.is_handled(*index));
- let Some(change) = shown.flat_map(|(_, range)| range.diffs(input)).find(|diff| diff.modified.contains(line_number)) else { return Vec::new() };
+ let shown = model.ranges.iter().enumerate().filter(|(index, range)| range.is_conflicting() || !model.is_handled(*index) || show_non_conflicting);
+ let Some(change) = shown.flat_map(|(_, range)| range.diffs(input)).find(|diff| diff.original.contains(line_number)) else { return Vec::new() };
+ self.merge_change_decorations(change, ZoneSide::Original, &editor.document().lines[index], editor.document().indentation.tab_size, line_number, char_width, 0.)
+ }
+
+ /// The whole-line background of `change` on one line, then its changed characters on `side`.
+ #[allow(clippy::too_many_arguments)]
+ fn merge_change_decorations(&self, change: &diff::LineRangeMapping, side: ZoneSide, text: &str, tab_size: usize, line_number: usize, char_width: f32, scroll_left: f32) -> Vec<Div> {
let mut decorations = vec![div().absolute().inset_0().left(px(scroll_left)).bg(self.color("mergeEditor.change.background"))];
let word = self.color("mergeEditor.change.word.background");
- let (text, tab_size) = (&editor.document().lines[index], editor.document().indentation.tab_size);
- for (left, width) in char_ranges(change, ZoneSide::Modified, line_number, text, tab_size, char_width, false) {
+ for (left, width) in char_ranges(change, side, line_number, text, tab_size, char_width, false) {
decorations.push(div().absolute().top_0().h_full().left(px(left)).w(px(width)).bg(word));
}
decorations
@@ -1014,7 +1054,8 @@ impl Workbench {
/// baseCodeEditorView.ts: the title bar over base's read-only lines, its zones and range blocks.
fn merge_base_pane(&self, merge: &MergeInput, zones: &[Zone], scroll_top: f32, window: &mut Window, cx: &mut Context<Self>) -> Div {
- let container = div().flex().flex_col().child(self.merge_title("Base", None, None));
+ let comparing = merge.focused_input.map(|input| format!("Comparing with {}", input_title(merge, input)));
+ let container = div().flex().flex_col().child(self.merge_title("Base", comparing.as_deref(), None));
let (Some(editor), Some(model)) = (self.editors.model(&merge.base.scheme, &merge.base.path), merge.model.as_ref()) else { return container };
container.child(self.merge_base_lines(model, editor, zones, scroll_top, window, cx))
}
@@ -1054,8 +1095,10 @@ impl Workbench {
continue;
}
let lines = range.base;
- let block_top = self.merge_line_top(zones, lines.start) - scroll_top;
- let block_height = if lines.is_empty() { 2. } else { self.merge_line_top(zones, lines.end - 1) + line_height - scroll_top - block_top };
+ // blockDecorations.ts: from the top of the zones above the first line to the bottom of the zones below the last.
+ let top_above_zones = if lines.start > 1 { self.merge_line_top(zones, lines.start - 1) + line_height } else { 0. };
+ let bottom = self.merge_line_top(zones, if lines.is_empty() { lines.start } else { lines.end });
+ let (block_top, block_height) = (top_above_zones - scroll_top, bottom - top_above_zones);
if block_top + block_height < 0. || block_top > height {
continue;
}
@@ -1094,7 +1137,8 @@ impl Workbench {
let target_state = state.with_input(input, !checked, false);
let id = if input == Input::One { ("merge-checkbox1", index) } else { ("merge-checkbox2", index) };
div()
- .w(px(GUTTER_WIDTH))
+ .debug_selector(move || format!("{}-{}", id.0, id.1))
+ .w(px(MARKER_WIDTH))
.h(px(block_height.max(size)))
.when(multi_line, |marker| marker.child(border.border_r_0().rounded_l(px(3.)).left(px(12.)).w(px(10.)).top_0().bottom_0()))
.child(
@@ -1123,7 +1167,7 @@ impl Workbench {
let text = &editor.document().lines[index];
let tab_size = editor.document().indentation.tab_size;
let highlights = editor.document().tokens.highlights(&self.theme, &self.languages, &editor.document().lines, index, tab_size);
- let content = div().absolute().top_0().bottom_0().right_0().left(px(metrics.content_left())).child(div().absolute().top_0().left_0().whitespace_nowrap().child(StyledText::new(expand_tabs(text, tab_size)).with_highlights(highlights)));
+ let content = div().absolute().top_0().bottom_0().right_0().left(px(metrics.content_left())).children(self.merge_base_decorations(editor, index, metrics.char_width)).child(div().absolute().top_0().left_0().whitespace_nowrap().child(StyledText::new(expand_tabs(text, tab_size)).with_highlights(highlights)));
div()
.h(px(metrics.line_height))
.flex()
@@ -1172,12 +1216,13 @@ async fn open_initial_result(workbench: &gpui::WeakEntity<Workbench>, cx: &mut g
}
}
-/// The top and height of the block around `lines` in `editor`, below the zones above it.
+/// blockDecorations.ts `render` of the block around `lines` in `editor`, its top and height: from the top of the zones
+/// above the first line to the bottom of the zones below the last; an empty range takes only the zones above it.
fn merge_block_span(editor: &OpenEditor, viewport: crate::editor::Viewport, lines: LineRange) -> (f32, f32) {
- let top = |index: usize| editor.line_top(editor.view_line(index), viewport) - editor.scroll.top;
- let block_top = top(lines.start - 1);
- let height = if lines.is_empty() { 2. } else { top(lines.end - 2) + viewport.line_height - block_top };
- (block_top, height)
+ let first = editor.view_line(lines.start - 1);
+ let top_above_zones = if first == 0 { viewport.line_top(0) } else { editor.line_top(first - 1, viewport) + viewport.line_height };
+ let bottom = if lines.is_empty() { editor.line_top(first, viewport) } else { editor.line_top(editor.view_line(lines.end - 2) + 1, viewport) };
+ (top_above_zones - editor.scroll.top, bottom - top_above_zones)
}
/// viewModel.ts `getRangeOfModifiedBaseRange`: range `index` in the focused input, else in the result.
diff --git a/native/crates/app/src/workbench/editor_view/merge_editor_view/tests.rs b/native/crates/app/src/workbench/editor_view/merge_editor_view/tests.rs
index 6cb79fd5267..ac033e8c8d4 100644
--- a/native/crates/app/src/workbench/editor_view/merge_editor_view/tests.rs
+++ b/native/crates/app/src/workbench/editor_view/merge_editor_view/tests.rs
@@ -13,6 +13,11 @@ use crate::theme::load_theme;
use crate::workbench::Workbench;
fn workbench_in<'a>(name: &str, cx: &'a mut TestAppContext) -> (PathBuf, gpui::Entity<Workbench>, Receiver<HostMessage>, &'a mut VisualTestContext) {
+ workbench_with_folder(name, false, cx)
+}
+
+/// `workbench_in`, with the files' folder open as the workspace when `folder` is set.
+fn workbench_with_folder<'a>(name: &str, folder: bool, cx: &'a mut TestAppContext) -> (PathBuf, gpui::Entity<Workbench>, Receiver<HostMessage>, &'a mut VisualTestContext) {
let app_root = Path::new(env!("VSCODE_SRC")).to_path_buf();
let themes = scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap();
let theme = load_theme(&[themes], "Dark Modern").unwrap();
@@ -25,7 +30,8 @@ fn workbench_in<'a>(name: &str, cx: &'a mut TestAppContext) -> (PathBuf, gpui::E
std::fs::write(dir.join("result.txt"), "one\n<<<<<<< HEAD\nTWO current\n=======\nTWO incoming\n>>>>>>> theirs\nthree").unwrap();
let (sender, receiver) = channel();
let settings = std::sync::Arc::new(std::sync::Mutex::new(config::service::Settings::load(config::registry::Registry::with_extensions(&[]), dir.join("User"), None)));
- let (workbench, cx) = cx.add_window_view(|_, cx| Workbench::new(theme, app_root.clone(), None, Languages::new(&[]), settings, HostSync::new(sender), cx));
+ let workspace = folder.then(|| config::workspace::Workspace::folder(dir.clone()));
+ let (workbench, cx) = cx.add_window_view(|_, cx| Workbench::new(theme, app_root.clone(), workspace, Languages::new(&[]), settings, HostSync::new(sender), cx));
(dir, workbench, receiver, cx)
}
@@ -195,6 +201,10 @@ fn the_cursor_keys_move_and_select_in_a_focused_input(cx: &mut TestAppContext) {
(editor.model_id, editor.selection().anchor, editor.selection().head, workbench.active_merge_range(), workbench.active_editor_readonly().is_some())
});
assert_eq!(state, (input1, Position::new(3, 0), Position::new(3, 1), Some(1), true));
+ // viewCursors.ts `_getCursorBlinking`: a read-only editor's cursor stays solid.
+ cx.executor().advance_clock(std::time::Duration::from_millis(500));
+ cx.run_until_parked();
+ assert!(!workbench.read_with(cx, |workbench, _| workbench.cursor_blink.borrow().hidden), "the input's cursor does not blink");
std::fs::remove_dir_all(dir).unwrap();
}
@@ -239,6 +249,106 @@ fn the_result_and_the_inputs_scroll_together(cx: &mut TestAppContext) {
std::fs::remove_dir_all(dir).unwrap();
}
+/// codeEditorView.ts `checkboxesVisible`: `mergeEditor.showCheckboxes` defaults to false, the 24px gutter stays empty.
+#[gpui::test]
+fn the_accept_checkboxes_show_only_with_show_checkboxes(cx: &mut TestAppContext) {
+ let (dir, workbench, _receiver, cx) = workbench_in("merge-checkboxes", cx);
+ open_with_keybindings(&workbench, &dir, cx);
+ assert_eq!(cx.debug_bounds("merge-input1-gutter").unwrap().size.width, gpui::px(24.));
+ assert!(cx.debug_bounds("merge-checkbox1-0").is_none(), "no checkbox by default");
+ std::fs::create_dir_all(dir.join("User")).unwrap();
+ std::fs::write(dir.join("User/settings.json"), r#"{ "mergeEditor.showCheckboxes": true }"#).unwrap();
+ workbench.update(cx, |workbench, cx| {
+ drop(workbench.settings.lock().unwrap().reload_changed_files());
+ cx.notify();
+ });
+ cx.run_until_parked();
+ assert!(cx.debug_bounds("merge-checkbox1-0").is_some());
+ std::fs::remove_dir_all(dir).unwrap();
+}
+
+/// blockDecorations.ts `render`: a range's `merge-editor-block` starts at the top of the zones above its first line,
+/// so it takes in the action row, and ends below its last line.
+#[gpui::test]
+fn a_ranges_block_takes_in_its_action_row(cx: &mut TestAppContext) {
+ let (dir, workbench, _receiver, cx) = workbench_in("merge-block", cx);
+ open_with_keybindings(&workbench, &dir, cx);
+ for side in ["merge-input1-action", "merge-result-action"] {
+ let row = cx.debug_bounds(format!("{side}-row-0").leak()).unwrap();
+ let block = cx.debug_bounds(format!("{side}-block-0").leak()).unwrap();
+ assert_eq!(block.top(), row.top(), "{side}: the block starts at its action row");
+ assert!(block.bottom() > row.bottom(), "{side}: the block takes in the range's lines");
+ }
+ std::fs::remove_dir_all(dir).unwrap();
+}
+
+/// resultCodeEditorView.ts: the description is the result's workspace-relative path; mergeEditor.css
+/// `.code-view.result > .header > .description`: a long one shrinks, the counter and Complete Merge keep their place.
+#[gpui::test]
+fn a_long_result_path_is_cut_before_the_conflict_counter(cx: &mut TestAppContext) {
+ let (dir, workbench, _receiver, cx) = workbench_with_folder("merge-long-path", true, cx);
+ let long = dir.join("a".repeat(200));
+ std::fs::create_dir_all(&long).unwrap();
+ std::fs::copy(dir.join("result.txt"), long.join("result.txt")).unwrap();
+ let args = json!({ "base": file_uri(&dir.join("base.txt")), "input1": { "uri": file_uri(&dir.join("incoming.txt")) }, "input2": { "uri": file_uri(&dir.join("current.txt")) }, "output": file_uri(&long.join("result.txt")) });
+ run(&workbench, cx, "_open.mergeEditor", vec![args]);
+ cx.run_until_parked();
+ let width = cx.update(|window, _| window.viewport_size().width);
+ let path = cx.debug_bounds("merge-result-path").unwrap();
+ let counter = cx.debug_bounds("merge-counter").unwrap();
+ let complete = cx.debug_bounds("merge-complete").unwrap();
+ assert!(path.right() <= counter.left(), "the path {path:?} ends before the counter {counter:?}");
+ assert!(complete.right() <= width, "Complete Merge {complete:?} stays in the window {width:?}");
+ let shown = workbench.read_with(cx, |workbench, _| workbench.merge_result_path(workbench.merge_result().unwrap()));
+ assert_eq!(shown, format!("{}/result.txt", "a".repeat(200)), "the path is relative to the folder");
+ std::fs::remove_dir_all(dir).unwrap();
+}
+
+/// breadcrumbsControl.ts: the merge editor's input resource is the result, its breadcrumbs show the result's path.
+#[gpui::test]
+fn the_merge_editor_shows_the_results_breadcrumbs(cx: &mut TestAppContext) {
+ let (dir, workbench, _receiver, cx) = workbench_in("merge-breadcrumbs", cx);
+ open_with_keybindings(&workbench, &dir, cx);
+ assert!(cx.debug_bounds("breadcrumb-item-0").is_some());
+ std::fs::remove_dir_all(dir).unwrap();
+}
+
+/// resultCodeEditorView.ts and baseCodeEditorView.ts `decorations`: the result marks its base-to-result diff of the
+/// conflicting range; base marks what the last focused input changes and names it in "Comparing with".
+#[gpui::test]
+fn the_result_and_base_mark_their_diffs(cx: &mut TestAppContext) {
+ let (dir, workbench, _receiver, cx) = workbench_in("merge-result-diff", cx);
+ open_with_keybindings(&workbench, &dir, cx);
+ let marked = |cx: &mut VisualTestContext| {
+ workbench.read_with(cx, |workbench, _| {
+ let merge = workbench.editors.active_merge().unwrap();
+ let result = workbench.merge_result().unwrap();
+ let base = workbench.editors.model(&merge.base.scheme, &merge.base.path).unwrap();
+ let result_lines: Vec<usize> = (0..7).filter(|&index| !workbench.merge_line_decorations(result, index, 7., 0.).is_empty()).collect();
+ let base_lines: Vec<usize> = (0..3).filter(|&index| !workbench.merge_base_decorations(base, index, 7.).is_empty()).collect();
+ (result_lines, base_lines)
+ })
+ };
+ assert_eq!(marked(cx), (vec![], vec![]), "the result starts as base, base compares with no input");
+ run(&workbench, cx, "merge.goToNextUnhandledConflict", Vec::new());
+ run(&workbench, cx, "merge.toggleActiveConflictInput1", Vec::new());
+ workbench.update(cx, |workbench, cx| workbench.update_merge_editor(cx));
+ assert_eq!(marked(cx).0, vec![1], "the accepted line of the conflict differs from base");
+ workbench.update_in(cx, |workbench, window, cx| {
+ let input1 = workbench.editors.active_merge().unwrap().input_editors[0].as_ref().unwrap().model_id;
+ workbench.focus_code_editor(input1, window, cx);
+ });
+ cx.run_until_parked();
+ assert_eq!(marked(cx).1, vec![1], "base marks the line input 1 changes");
+ // mergeEditor.ts `getControl` is the result's editor; textFileEditorTracker.ts sees the dirty result as opened.
+ let (control, result) = workbench.read_with(cx, |workbench, _| (workbench.active_text_editor_control().unwrap().model_id, workbench.merge_result().unwrap().model_id));
+ assert_eq!(control, result, "the breadcrumbs and the status bar follow the result while input 1 has the focus");
+ cx.executor().advance_clock(std::time::Duration::from_millis(1000));
+ cx.run_until_parked();
+ assert_eq!(workbench.read_with(cx, |workbench, _| workbench.editors.editors.len()), 1, "the dirty result opens no tab of its own");
+ std::fs::remove_dir_all(dir).unwrap();
+}
+
/// Opens the merge editor of the files in `dir` with the default keybindings and the result focused.
fn open_with_keybindings(workbench: &gpui::Entity<Workbench>, dir: &Path, cx: &mut VisualTestContext) {
let args = json!({ "base": file_uri(&dir.join("base.txt")), "input1": { "uri": file_uri(&dir.join("incoming.txt")) }, "input2": { "uri": file_uri(&dir.join("current.txt")) }, "output": file_uri(&dir.join("result.txt")) });
diff --git a/native/crates/app/src/workbench/text_file_editor_tracker.rs b/native/crates/app/src/workbench/text_file_editor_tracker.rs
index b0f1cfe43a1..c7af5b059f1 100644
--- a/native/crates/app/src/workbench/text_file_editor_tracker.rs
+++ b/native/crates/app/src/workbench/text_file_editor_tracker.rs
@@ -58,7 +58,8 @@ impl Workbench {
continue;
}
let mut tabs = self.editors.editors.iter().chain(self.editors.other_groups.iter().flat_map(|group| &group.editors));
- if !tabs.any(|tab| tab.document().is(&scheme, &path)) {
+ // editorService.ts `isOpened` matches an editor's resource: a diff or merge editor's edited side.
+ if !tabs.any(|tab| self.editors.editor_model(tab).document().is(&scheme, &path)) {
self.editors.open_inactive(&scheme, &path);
}
}
diff --git a/port/ledger.md b/port/ledger.md
index 685fc7c6223..034927a899e 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -509,7 +509,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/contrib/markers | workbench contribution | M13 | verified | | markersTreeViewer.ts `MarkerViewModel`: each marker keeps its quick fixes, asked once, until its resource's markers change (cargo test -p app each_problems_marker_keeps_its_quick_fixes). Indent guides and the focused row's outline apart from the selection (cargo test -p app the_focus_outline_follows). status bar problems entry and tooltip from markers (workbench/diagnostics.rs), its click toggles the Problems view; the Problems panel view (workbench/problems_view.rs: resources by worst severity then path, markers by severity then position, count badges, the tab badge, open on click, Collapse All, `workbench.actions.view.problems` and `toggleProblems`): cargo test -p app problems_view the_debug_console_and_test_results_are_panel_views, ui-pair port/results/problems.md; MarkersFileDecorations (count letter, error/warning color, bubbling, weight over other providers, `problems.decorations.enabled`) on Explorer rows and tabs (workbench/file_decorations.rs): cargo test -p app problems_decorate_the_file; filter box (workbench/view_filter.rs in the panel title at the panel's filter width, markers_filter.rs: markersFilterOptions.test.ts cases; text, `!`, globs, `@source:`, severity, active file and excluded files toggles, filter history, memento), filters menu, related information and multi-line rows, View as Table with column sashes (workbench/problems_table.rs), quick fixes on hovered rows (workbench/problems_quick_fix.rs): cargo test -p app markers_filter problems_view problems_table; ui-pair port/fixtures/problems/steps-filter.json and steps-table.json (port/results/problems.md); the selected row (first marker on focus, Up/Down, Enter and Cmd+Down open, `problems.action.copy`/`copyMessage`/`copyRelatedInformationMessage`, Cmd+. on the selected marker, `problemFocus`/`relatedInformationFocus`): cargo test -p app problems; ui-pair .vscode/settings.json and e.ts quick fix (port/results/language-features.md JSON settings, Problems quick fix). Multi-selection in the tree (`multipleSelectionSupport`: Shift+Up/Down, Cmd+click toggles, Shift+click ranges from the anchor, Copy over `getFocusedSelectedElements`) and open to the side (`problems.action.openToSide` on Ctrl+Enter, Ctrl/Cmd/Alt+click as listService.ts `sideBySide`, into `SIDE_GROUP`): cargo test -p app markers_select_together_and_open_to_the_side. Resource row: name 30px in, count badge 19px round 10px after the label at the line's bottom (cargo test -p app the_resource_name_sits_after_the_twistie_at_its_exact_line_height; ui-pair problems: chevron, icon x, name, description and badge box at the reference's device pixels, the file icon and the badge digit 1 device px low); a hovered marker without a model gets its quick fixes once its file opens (markersTreeViewer.ts `getModel(waitForModel)`; cargo test -p app a_problems_marker_gets_its_quick_fixes_once_its_file_opens) |
| workbench/contrib/mcp | workbench contribution | | removed | | no sign-in/AI by decision (port/notes.md); not ported |
| workbench/contrib/mediaPreview | workbench contribution | M17 | ported | [3 M] media_preview.rs:101, :156: non-file resources; mediaCodecs.ts | An image or media file previewed in another group gets a preview of its own in the active group (mediaPreview.contribution.ts registers without `singlePerResource`: cargo test -p app an_image_previewed_in_another_group_gets_a_preview_in_the_active_one); image, video and audio previews as built-in editors (workbench/media_preview.rs, pages in media_preview/*.html), resolver priority builtin, zoom commands and Select Zoom Level picker, zoom, dimensions and file size status entries, Reopen as Source Text / Image Preview, the file's tab icon and Explorer reveal; `FIXTURE=media-preview-tests port/tools/webview-check` 6/6 on both apps; cargo test -p app media_preview; ui-pair image, video and audio, the breadcrumbs bar with the editor type control and its Reopen/Set Default menu (editor-type-reopen.json; port/results/webviews.md); cargo test -p app lists_the_editor_types; the focus outline at open (ui-pair media-preview-focus.json, background and foreground); cargo test -p app opens_a_startup_image. Not done: codec probing (mediaCodecs.ts), Copy image, legacy `media-preview` editor migration |
-| workbench/contrib/mergeEditor | workbench contribution | M14 | ported | [3 L] merge_editor_view.rs:5: no base-to-result diff backgrounds in the result, no "Comparing with" highlights in base <br> [3 S] merge_editor_view.rs:925: the inputs show the accept checkboxes' gutter, which `mergeEditor.showCheckboxes` (default false, codeEditorView.ts) hides <br> [3 S] merge_editor_view.rs:953: a range's block border leaves out its action row above the range, which the reference's `merge-editor-block` takes in <br> [3 S] merge_editor_view.rs:866: the result title's path is not cut short and runs under the conflict counter and Complete Merge <br> [3 S] editor_view.rs:159: no breadcrumbs row over the merge editor, which the reference shows with the result's path | merge_editor.rs model (mapping, conflict states, accept/combine) and workbench/editor_view/merge_editor_view.rs (input 1/2, result, base view, layouts, gutter checkboxes, `_open.mergeEditor`, dev commands, the inputs as read-only code editors of the group, Toggle Between Inputs, the active range in the last focused input or the result, scroll synchronization): cargo test -p app merge |
+| workbench/contrib/mergeEditor | workbench contribution | M14 | ported | [3 M] merge_editor_view.rs:896: the result title always draws a Complete Merge button; the reference has none there, git's `git.acceptMerge` shows it in the result's `editor/content` floating menu only while `mergeEditorResultUri in git.mergeChanges` | merge_editor.rs model (mapping, conflict states, accept/combine) and workbench/editor_view/merge_editor_view.rs (input 1/2, result, base view, layouts, gutter checkboxes behind `mergeEditor.showCheckboxes`, base-to-result diff backgrounds, "Comparing with" in base, the result's breadcrumbs, `_open.mergeEditor`, dev commands, the inputs as read-only code editors of the group, Toggle Between Inputs, the active range in the last focused input or the result, scroll synchronization): cargo test -p app merge |
| workbench/contrib/meteredConnection | workbench contribution | M19 | verified | | the metered warning status entry and Configure Metered Connection (workbench/power.rs); port/tools/shell-check (port/fixtures/extensions/shell-tests, 6/6); cargo test -p app metered_connection |
| workbench/contrib/modernUI | workbench contribution | M11 | verified | | the modern layout only: the classic layout (`workbench.experimental.modernUI: false`) is removed by Artur's decision (port/notes.md Modern UI); `window.density.layout` compact and the Manage menu's Layout Density (cargo test -p app -- compact_density layout_density; ui-pair m11/layout-density.json in both densities with SETTINGS `{"window.density.layout": "compact"}`, port/results/layout-density.md) |
| workbench/contrib/multiDiffEditor | workbench contribution | M14 | verified | | multi_diff_editor.rs and workbench/editor_view/multi_diff_editor_view.rs: `_workbench.openMultiDiffEditor`, SCM group (following the group's splices, each kept file with its state) and history item sources, Open File with the history item's `goToFileEditorTitle`, file toolbar, change navigation, collapse, binary placeholder, unchanged bars that click or drag with the line below kept in place and the hidden range's outline breadcrumbs (cargo test -p app unchanged_bars_drag), the layout debug log in the side group with a JSON patch line per change, the file list's Files View & Position sides, its sash with the stored width and hiding below 560px, View as List/Tree with the diffs in the list's order, each file's 35px diff gutter with Revert Block, the diff editor's line number lane, the `noCards` variant, first change selected and focused on open: cargo test -p app multi_diff. Each file side is its own code editor (workbench/code_editors.rs): a press focuses it, the modified side takes typing, undo, selection, IME, find and suggest, the host gets the file's edit, the edit recomputes the file's diff and makes the tab dirty and pinned, the dirty file opens as an inactive tab after 800ms (textFileEditorTracker.ts), the focused side's cursor blinks, every drawn side has its own color decorators, bracket pair colors come from the model: cargo test -p app a_file_side_is_a_code_editor every_drawn_file_side; ui-pair `steps-multi-diff-edit.json` (typed, undone, find) matches but for the reference's TypeScript diagnostics (port/notes.md, Comments in diff editors) |