Skip to content

Commit

Permalink
Merge pull request #165423 from Mingpan/mingpan/fix-diff-revert-arrows
Browse files Browse the repository at this point in the history
Fix arrows in side-by-side diff view
  • Loading branch information
hediet committed Nov 4, 2022
2 parents 5e47d25 + bd254f9 commit db0c4da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/vs/editor/browser/widget/diffEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,12 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._register(editor.onMouseDown(event => {
if (!event.event.rightButton && event.target.position && event.target.element?.className.includes('arrow-revert-change')) {
const lineNumber = event.target.position.lineNumber;
const change = this._diffComputationResult?.changes.find(c => c.modifiedStartLineNumber === lineNumber - 1 || c.modifiedStartLineNumber === lineNumber);
const viewZone = event.target as editorBrowser.IMouseTargetViewZone | undefined;
const change = this._diffComputationResult?.changes.find(c =>
// delete change
viewZone?.detail.afterLineNumber === c.modifiedStartLineNumber ||
// other changes
(c.modifiedEndLineNumber > 0 && c.modifiedStartLineNumber === lineNumber));
if (change) {
this.revertChange(change);
}
Expand Down Expand Up @@ -1208,7 +1213,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
const foreignOriginal = this._originalEditorState.getForeignViewZones(this._originalEditor.getWhitespaces());
const foreignModified = this._modifiedEditorState.getForeignViewZones(this._modifiedEditor.getWhitespaces());

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

try {
this._currentlyChangingViewZones = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const fixedDiffEditorOptions: IDiffEditorConstructionOptions = {
glyphMargin: true,
enableSplitViewResizing: false,
renderIndicators: true,
renderMarginRevertIcon: false,
readOnly: false,
isInEmbeddedEditor: true,
renderOverviewRuler: false,
Expand Down

0 comments on commit db0c4da

Please sign in to comment.