mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Fixes #199328
This commit is contained in:
parent
0c27dae0e6
commit
4d2d0582c6
|
@ -310,27 +310,27 @@ export class DiffEditorViewModel extends Disposable implements IDiffEditorViewMo
|
|||
}));
|
||||
}
|
||||
|
||||
public ensureModifiedLineIsVisible(lineNumber: number, tx: ITransaction | undefined): void {
|
||||
public ensureModifiedLineIsVisible(lineNumber: number, preference: RevealPreference, tx: ITransaction | undefined): void {
|
||||
if (this.diff.get()?.mappings.length === 0) {
|
||||
return;
|
||||
}
|
||||
const unchangedRegions = this._unchangedRegions.get()?.regions || [];
|
||||
for (const r of unchangedRegions) {
|
||||
if (r.getHiddenModifiedRange(undefined).contains(lineNumber)) {
|
||||
r.showModifiedLine(lineNumber, tx);
|
||||
r.showModifiedLine(lineNumber, preference, tx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ensureOriginalLineIsVisible(lineNumber: number, tx: ITransaction | undefined): void {
|
||||
public ensureOriginalLineIsVisible(lineNumber: number, preference: RevealPreference, tx: ITransaction | undefined): void {
|
||||
if (this.diff.get()?.mappings.length === 0) {
|
||||
return;
|
||||
}
|
||||
const unchangedRegions = this._unchangedRegions.get()?.regions || [];
|
||||
for (const r of unchangedRegions) {
|
||||
if (r.getHiddenOriginalRange(undefined).contains(lineNumber)) {
|
||||
r.showOriginalLine(lineNumber, tx);
|
||||
r.showOriginalLine(lineNumber, preference, tx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -589,20 +589,20 @@ export class UnchangedRegion {
|
|||
this._visibleLineCountBottom.set(this.lineCount - this._visibleLineCountTop.get(), tx);
|
||||
}
|
||||
|
||||
public showModifiedLine(lineNumber: number, tx: ITransaction | undefined): void {
|
||||
public showModifiedLine(lineNumber: number, preference: RevealPreference, tx: ITransaction | undefined): void {
|
||||
const top = lineNumber + 1 - (this.modifiedLineNumber + this._visibleLineCountTop.get());
|
||||
const bottom = (this.modifiedLineNumber - this._visibleLineCountBottom.get() + this.lineCount) - lineNumber;
|
||||
if (top < bottom) {
|
||||
if (preference === RevealPreference.FromCloserSide && top < bottom || preference === RevealPreference.FromTop) {
|
||||
this._visibleLineCountTop.set(this._visibleLineCountTop.get() + top, tx);
|
||||
} else {
|
||||
this._visibleLineCountBottom.set(this._visibleLineCountBottom.get() + bottom, tx);
|
||||
}
|
||||
}
|
||||
|
||||
public showOriginalLine(lineNumber: number, tx: ITransaction | undefined): void {
|
||||
public showOriginalLine(lineNumber: number, preference: RevealPreference, tx: ITransaction | undefined): void {
|
||||
const top = lineNumber - this.originalLineNumber;
|
||||
const bottom = (this.originalLineNumber + this.lineCount) - lineNumber;
|
||||
if (top < bottom) {
|
||||
if (preference === RevealPreference.FromCloserSide && top < bottom || preference === RevealPreference.FromTop) {
|
||||
this._visibleLineCountTop.set(Math.min(this._visibleLineCountTop.get() + bottom - top, this.getMaxVisibleLineCountTop()), tx);
|
||||
} else {
|
||||
this._visibleLineCountBottom.set(Math.min(this._visibleLineCountBottom.get() + top - bottom, this.getMaxVisibleLineCountBottom()), tx);
|
||||
|
@ -623,6 +623,12 @@ export class UnchangedRegion {
|
|||
}
|
||||
}
|
||||
|
||||
export const enum RevealPreference {
|
||||
FromCloserSide,
|
||||
FromTop,
|
||||
FromBottom,
|
||||
}
|
||||
|
||||
function applyOriginalEdits(diff: IDocumentDiff, textEdits: TextEditInfo[], originalTextModel: ITextModel, modifiedTextModel: ITextModel): IDocumentDiff | undefined {
|
||||
return undefined;
|
||||
/*
|
||||
|
|
|
@ -15,7 +15,7 @@ import { isDefined } from 'vs/base/common/types';
|
|||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { DiffEditorEditors } from 'vs/editor/browser/widget/diffEditor/components/diffEditorEditors';
|
||||
import { DiffEditorOptions } from 'vs/editor/browser/widget/diffEditor/diffEditorOptions';
|
||||
import { DiffEditorViewModel, UnchangedRegion } from 'vs/editor/browser/widget/diffEditor/diffEditorViewModel';
|
||||
import { DiffEditorViewModel, RevealPreference, UnchangedRegion } from 'vs/editor/browser/widget/diffEditor/diffEditorViewModel';
|
||||
import { IObservableViewZone, PlaceholderViewZone, ViewZoneOverlayWidget, applyObservableDecorations, applyStyle } from 'vs/editor/browser/widget/diffEditor/utils';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { LineRange } from 'vs/editor/common/core/lineRange';
|
||||
|
@ -63,8 +63,8 @@ export class HideUnchangedRegionsFeature extends Disposable {
|
|||
const m = this._diffModel.get();
|
||||
transaction(tx => {
|
||||
for (const s of this._editors.original.getSelections() || []) {
|
||||
m?.ensureOriginalLineIsVisible(s.getStartPosition().lineNumber, tx);
|
||||
m?.ensureOriginalLineIsVisible(s.getEndPosition().lineNumber, tx);
|
||||
m?.ensureOriginalLineIsVisible(s.getStartPosition().lineNumber, RevealPreference.FromCloserSide, tx);
|
||||
m?.ensureOriginalLineIsVisible(s.getEndPosition().lineNumber, RevealPreference.FromCloserSide, tx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ export class HideUnchangedRegionsFeature extends Disposable {
|
|||
const m = this._diffModel.get();
|
||||
transaction(tx => {
|
||||
for (const s of this._editors.modified.getSelections() || []) {
|
||||
m?.ensureModifiedLineIsVisible(s.getStartPosition().lineNumber, tx);
|
||||
m?.ensureModifiedLineIsVisible(s.getEndPosition().lineNumber, tx);
|
||||
m?.ensureModifiedLineIsVisible(s.getStartPosition().lineNumber, RevealPreference.FromCloserSide, tx);
|
||||
m?.ensureModifiedLineIsVisible(s.getEndPosition().lineNumber, RevealPreference.FromCloserSide, tx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ export class HideUnchangedRegionsFeature extends Disposable {
|
|||
r.originalUnchangedRange,
|
||||
!sideBySide,
|
||||
modifiedOutlineSource,
|
||||
l => this._diffModel.get()!.ensureModifiedLineIsVisible(l, undefined),
|
||||
l => this._diffModel.get()!.ensureModifiedLineIsVisible(l, RevealPreference.FromBottom, undefined),
|
||||
this._options,
|
||||
));
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ export class HideUnchangedRegionsFeature extends Disposable {
|
|||
r.modifiedUnchangedRange,
|
||||
false,
|
||||
modifiedOutlineSource,
|
||||
l => this._diffModel.get()!.ensureModifiedLineIsVisible(l, undefined),
|
||||
l => this._diffModel.get()!.ensureModifiedLineIsVisible(l, RevealPreference.FromBottom, undefined),
|
||||
this._options,
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue