feat(vcs): settings to hide the change markers in the gutter and on the scrollbar (#6558)

Editor > General gets a Gutter section with "Highlight modified lines in the gutter" and, under it, "Highlight modified lines in error stripe on the scrollbar". Both are on by default; turning off the first hides the scrollbar marks too, and the change applies to open editors right away through a changeMarkerDisplay facet set from the prefs compartment.

Fixes #6539
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-28 02:01:47 +08:00
1 джерело 11a8152988
коміт 1fc9a9f5d5
12 files changed
+96 -5

No files matched your search

+6
Переглянути файл
@@ -33,6 +33,10 @@ pub struct EditorGeneralSettings {
pub remove_trailing_blank_lines: bool,
/// Copy as rich text (HTML with syntax colours) by default.
pub rich_text_copy: bool,
/// Gutter › Highlight modified lines in the gutter: the VCS change bars next to the line numbers.
pub highlight_modified_lines: bool,
/// Gutter › Highlight modified lines in error stripe on the scrollbar (with `highlight_modified_lines`).
pub highlight_modified_lines_in_scrollbar: bool,
}
impl Default for EditorGeneralSettings {
@@ -51,6 +55,8 @@ impl Default for EditorGeneralSettings {
keep_trailing_on_caret_line: true,
remove_trailing_blank_lines: false,
rich_text_copy: true,
highlight_modified_lines: true,
highlight_modified_lines_in_scrollbar: true,
}
}
}
+4
Переглянути файл
@@ -6905,6 +6905,10 @@ export type EditorGeneralSettings = {
removeTrailingBlankLines?: boolean,
/** Copy as rich text (HTML with syntax colours) by default. */
richTextCopy?: boolean,
/** Gutter › Highlight modified lines in the gutter: the VCS change bars next to the line numbers. */
highlightModifiedLines?: boolean,
/** Gutter › Highlight modified lines in error stripe on the scrollbar (with `highlight_modified_lines`). */
highlightModifiedLinesInScrollbar?: boolean,
};
/**
+13
Переглянути файл
@@ -442,6 +442,19 @@ export const lineChanges = Facet.define<readonly LineChange[], readonly LineChan
combine: (values) => values[0] ?? [],
});
/**
* Settings › Editor › General › Gutter: where the VCS change markers show. Set from the
* editor settings; the scrollbar marks follow the gutter setting, as in IDEA.
*/
export interface ChangeMarkerDisplay {
gutter: boolean;
scrollbar: boolean;
}
export const changeMarkerDisplay = Facet.define<ChangeMarkerDisplay, ChangeMarkerDisplay>({
combine: (values) => values[0] ?? { gutter: true, scrollbar: true },
});
/** Marker for `gutterLaneMarkers`: a solid 3px bar (or a small wedge for `deleted`). */
export class LaneMarker extends GutterMarker {
constructor(
+8 -1
Переглянути файл
@@ -36,7 +36,7 @@ import {
import { markdownImages } from "./markdownImages";
import { selectionMarks } from "./selectionMarks";
import { seamlessSelection } from "./selectionLayer";
import { useEditorRegistry } from "@/editor/api";
import { changeMarkerDisplay, useEditorRegistry } from "@/editor/api";
import { editorPrefs, type EditorExtras } from "@/platform/editorSettings";
import { openideaHighlightStyle } from "./highlight";
import {
@@ -818,6 +818,13 @@ export function prefsExtension(o: PrefsOptions): Extension {
out.push(g.dragAndDrop ? textDrag : noTextDrag);
if (g.caretScroll === "center") out.push(centerCaret);
out.push(g.richTextCopy ? richCopyByDefault : plainCopyByDefault);
if (!g.highlightModifiedLines || !g.highlightModifiedLinesInScrollbar)
out.push(
changeMarkerDisplay.of({
gutter: g.highlightModifiedLines,
scrollbar: g.highlightModifiedLines && g.highlightModifiedLinesInScrollbar,
}),
);
if (k.escapeOnPaste) out.push(stringClipboard(o.language));
if (!o.readOnly && (k.reformatOnPaste === "indentBlock" || k.reformatOnPaste === "indentEachLine"))
out.push(pasteReindentFilter(k.reformatOnPaste));
+17
Переглянути файл
@@ -190,6 +190,23 @@ const GENERAL = editorPage({
},
],
},
{
title: "Gutter",
items: [
{
t: "check",
key: `${P}.general.highlightModifiedLines`,
label: "Highlight modified lines in the gutter",
children: [
{
t: "check",
key: `${P}.general.highlightModifiedLinesInScrollbar`,
label: "Highlight modified lines in error stripe on the scrollbar",
},
],
},
],
},
{
title: "Save Files",
items: [
+23
Переглянути файл
@@ -190,6 +190,29 @@ describe("change markers in folds", () => {
});
});
describe("change marker settings", () => {
it("hides the gutter bars and the scrollbar marks as Editor › General › Gutter says", async () => {
const { changeMarkerDisplay, gutterLaneMarkers, scrollbarMarks } = await import("@/editor/api");
const { changeMarkers } = await import("../gutter");
const shown = (display?: { gutter: boolean; scrollbar: boolean }) => {
const state = EditorState.create({
doc: "a\nB\nc\n",
extensions: [
changeMarkers({ path: "/p/f.txt" } as Parameters<typeof changeMarkers>[0]),
display ? changeMarkerDisplay.of(display) : [],
],
}).update({ effects: setHunksEffect.of([h("modified", 1, 1, 1, 1, "b\n")]) }).state;
return {
gutter: state.facet(gutterLaneMarkers).reduce((n, set) => n + set.size, 0),
scrollbar: state.facet(scrollbarMarks).length,
};
};
expect(shown()).toEqual({ gutter: 1, scrollbar: 1 });
expect(shown({ gutter: true, scrollbar: false })).toEqual({ gutter: 1, scrollbar: 0 });
expect(shown({ gutter: false, scrollbar: false })).toEqual({ gutter: 0, scrollbar: 0 });
});
});
describe("hunkKeys", () => {
it("identifies blocks by content, not position", () => {
const a = hunkKeys("x\nB\nc\n", [h("modified", 1, 1, 1, 1, "b\n")]);
+10 -3
Переглянути файл
@@ -11,6 +11,7 @@ import type { HunkKind, LineHunk } from "@/bindings";
import { call, commands, isTauri } from "@/platform/ipc";
import {
LaneMarker,
changeMarkerDisplay,
gutterLaneMarkers,
lineChanges,
scrollbarMarks,
@@ -389,7 +390,13 @@ class HunkFetcher implements PluginValue {
}
}
function scrollMarks(state: EditorState): ScrollbarMark[] {
/** The lane markers, unless Settings › Editor › General › Gutter turns them off. */
export function laneMarkers(state: EditorState): RangeSet<GutterMarker> {
return state.facet(changeMarkerDisplay).gutter ? visibleMarkers(state) : RangeSet.empty;
}
export function scrollMarks(state: EditorState): ScrollbarMark[] {
if (!state.facet(changeMarkerDisplay).scrollbar) return [];
return editorHunks(state).map((h) => ({
from: h.from,
to: h.to > h.from ? h.to - 1 : h.from,
@@ -466,8 +473,8 @@ export function changeMarkers(ctx: EditorDocContext): Extension {
const path = ctx.path;
return [
hunkField,
gutterLaneMarkers.compute([hunkField, foldState], visibleMarkers),
scrollbarMarks.compute([hunkField], scrollMarks),
gutterLaneMarkers.compute([hunkField, foldState, changeMarkerDisplay], laneMarkers),
scrollbarMarks.compute([hunkField, changeMarkerDisplay], scrollMarks),
laneClicks(path),
laneTheme,
ViewPlugin.define((view) => new HunkFetcher(view, path)),
+2
Переглянути файл
@@ -54,6 +54,8 @@ export const CLIENT_SETTINGS_KEYS = [
"editor.general.softWrapIndent",
"editor.general.scrollPastEnd",
"editor.general.richTextCopy",
"editor.general.highlightModifiedLines",
"editor.general.highlightModifiedLinesInScrollbar",
"editor.codeStyle.visualGuides",
"terminal.tabName",
"terminal.appTitleAsTabName",
+3
Переглянути файл
@@ -147,6 +147,9 @@ export const EDITOR_EXTRA_DEFAULTS = {
keepTrailingOnCaretLine: true,
removeTrailingBlankLines: false,
richTextCopy: true,
/** Gutter › Highlight modified lines in the gutter / in error stripe on the scrollbar. */
highlightModifiedLines: true,
highlightModifiedLinesInScrollbar: true,
},
appearance: {
caretBlinking: true,
+4 -1
Переглянути файл
@@ -4373,5 +4373,8 @@
"manage.py Tasks": "manage.py Tasks",
"Install django-types to complete Django model fields and managers": "Install django-types to complete Django model fields and managers",
"Installing django-types": "Installing django-types",
"Cannot install django-types": "Cannot install django-types"
"Cannot install django-types": "Cannot install django-types",
"Gutter": "Gutter",
"Highlight modified lines in the gutter": "Highlight modified lines in the gutter",
"Highlight modified lines in error stripe on the scrollbar": "Highlight modified lines in error stripe on the scrollbar"
}
+3
Переглянути файл
@@ -1671,6 +1671,9 @@
"Group by Severity": "按嚴重性分組",
"Groups": "群組",
"Gutter Icons": "裝訂區域圖示",
"Gutter": "裝訂區域",
"Highlight modified lines in the gutter": "在裝訂區域中醒目提示已修改的行",
"Highlight modified lines in error stripe on the scrollbar": "在捲軸的錯誤條紋中醒目提示已修改的行",
"HACK comment": "HACK 註解",
"HEAD (Current Branch)": "HEAD(目前分支)",
"HTML 5 file": "HTML 5 檔案",
+3
Переглянути файл
@@ -2130,6 +2130,9 @@
"Group by Severity": "按严重性分组",
"Groups": "组",
"Gutter Icons": "装订区域图标",
"Gutter": "装订区域",
"Highlight modified lines in the gutter": "在装订区域中突出显示已修改的行",
"Highlight modified lines in error stripe on the scrollbar": "在滚动条的错误条纹中突出显示已修改的行",
"HACK comment": "HACK 注释",
"HEAD (Current Branch)": "HEAD(当前分支)",
"HTML 5 file": "HTML 5 文件",