Fix arrows in side-by-side diff view

This commit is contained in:
Mingpan 2022-11-03 17:59:44 +01:00
parent 469ee9360d
commit bd254f9702
2 changed files with 9 additions and 2 deletions

View file

@ -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);
}
@ -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;

View file

@ -94,6 +94,7 @@ export const fixedDiffEditorOptions: IDiffEditorConstructionOptions = {
glyphMargin: true,
enableSplitViewResizing: false,
renderIndicators: true,
renderMarginRevertIcon: false,
readOnly: false,
isInEmbeddedEditor: true,
renderOverviewRuler: false,