Skip to content

Commit bd254f9

Browse files
committed
Fix arrows in side-by-side diff view
1 parent 469ee93 commit bd254f9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,12 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
610610
this._register(editor.onMouseDown(event => {
611611
if (!event.event.rightButton && event.target.position && event.target.element?.className.includes('arrow-revert-change')) {
612612
const lineNumber = event.target.position.lineNumber;
613-
const change = this._diffComputationResult?.changes.find(c => c.modifiedStartLineNumber === lineNumber - 1 || c.modifiedStartLineNumber === lineNumber);
613+
const viewZone = event.target as editorBrowser.IMouseTargetViewZone | undefined;
614+
const change = this._diffComputationResult?.changes.find(c =>
615+
// delete change
616+
viewZone?.detail.afterLineNumber === c.modifiedStartLineNumber ||
617+
// other changes
618+
(c.modifiedEndLineNumber > 0 && c.modifiedStartLineNumber === lineNumber));
614619
if (change) {
615620
this.revertChange(change);
616621
}
@@ -1208,7 +1213,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
12081213
const foreignOriginal = this._originalEditorState.getForeignViewZones(this._originalEditor.getWhitespaces());
12091214
const foreignModified = this._modifiedEditorState.getForeignViewZones(this._modifiedEditor.getWhitespaces());
12101215

1211-
const diffDecorations = this._strategy.getEditorsDiffDecorations(lineChanges, this._options.ignoreTrimWhitespace, this._options.renderIndicators, this._options.renderMarginRevertIcon, foreignOriginal, foreignModified);
1216+
const renderMarginRevertIcon = this._options.renderMarginRevertIcon && !this._modifiedEditor.getOption(EditorOption.readOnly);
1217+
const diffDecorations = this._strategy.getEditorsDiffDecorations(lineChanges, this._options.ignoreTrimWhitespace, this._options.renderIndicators, renderMarginRevertIcon, foreignOriginal, foreignModified);
12121218

12131219
try {
12141220
this._currentlyChangingViewZones = true;

src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const fixedDiffEditorOptions: IDiffEditorConstructionOptions = {
9494
glyphMargin: true,
9595
enableSplitViewResizing: false,
9696
renderIndicators: true,
97+
renderMarginRevertIcon: false,
9798
readOnly: false,
9899
isInEmbeddedEditor: true,
99100
renderOverviewRuler: false,

0 commit comments

Comments
 (0)