Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes some smaller diff editor bugs #191394

Merged
merged 1 commit into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/editor/browser/editorBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ export interface ICodeEditor extends editorCommon.IEditor {
/**
* Get the vertical position (top offset) for the line's top w.r.t. to the first line.
*/
getTopForLineNumber(lineNumber: number): number;
getTopForLineNumber(lineNumber: number, includeViewZones?: boolean): number;

/**
* Get the vertical position (top offset) for the line's bottom w.r.t. to the first line.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ export class DiffEditorOptions {
public readonly splitViewDefaultRatio = derived(reader => /** @description splitViewDefaultRatio */ this._options.read(reader).splitViewDefaultRatio);
public readonly ignoreTrimWhitespace = derived(reader => /** @description ignoreTrimWhitespace */ this._options.read(reader).ignoreTrimWhitespace);
public readonly maxComputationTimeMs = derived(reader => /** @description maxComputationTime */ this._options.read(reader).maxComputationTime);
public readonly showMoves = derived(reader => {
/** @description showMoves */
const o = this._options.read(reader);
return o.experimental.showMoves! && o.renderSideBySide;
});
public readonly showMoves = derived(reader => /** @description showMoves */ this._options.read(reader).experimental.showMoves! && this.renderSideBySide.read(reader));
public readonly isInEmbeddedEditor = derived(reader => /** @description isInEmbeddedEditor */ this._options.read(reader).isInEmbeddedEditor);
public readonly diffWordWrap = derived(reader => /** @description diffWordWrap */ this._options.read(reader).diffWordWrap);
public readonly originalEditable = derived(reader => /** @description originalEditable */ this._options.read(reader).originalEditable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export class MovedBlocksLinesPart extends Disposable {
}));
}

private readonly _modifiedViewZonesChangedSignal = observableSignalFromEvent('modified.onDidChangeViewZones', this._editors.modified.onDidChangeViewZones);
private readonly _originalViewZonesChangedSignal = observableSignalFromEvent('original.onDidChangeViewZones', this._editors.original.onDidChangeViewZones);

private readonly _state = derivedWithStore('state', (reader, store) => {
/** @description update moved blocks lines */

Expand All @@ -122,10 +125,13 @@ export class MovedBlocksLinesPart extends Disposable {
return;
}

this._modifiedViewZonesChangedSignal.read(reader);
this._originalViewZonesChangedSignal.read(reader);

const lines = moves.map((move) => {
function computeLineStart(range: LineRange, editor: ICodeEditor) {
const t1 = editor.getTopForLineNumber(range.startLineNumber);
const t2 = editor.getTopForLineNumber(range.endLineNumberExclusive);
const t1 = editor.getTopForLineNumber(range.startLineNumber, true);
const t2 = editor.getTopForLineNumber(range.endLineNumberExclusive, true);
return (t1 + t2) / 2;
}

Expand Down
28 changes: 14 additions & 14 deletions src/vs/editor/browser/widget/diffEditorWidget2/unchangedRanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,27 +360,27 @@ class CollapsedCodeOverlayWidget extends ViewZoneOverlayWidget {
/** @description update labels */

const children: HTMLElement[] = [];
if (!this.hide && true) {
if (!this.hide) {
const lineCount = _unchangedRegion.getHiddenModifiedRange(reader).length;
const linesHiddenText = localize('hiddenLines', '{0} Hidden Lines', lineCount);
children.push($('span', { title: linesHiddenText }, linesHiddenText));
}

const range = this._unchangedRegion.getHiddenModifiedRange(reader);
const items = this._modifiedOutlineSource.getBreadcrumbItems(range, reader);
const range = this._unchangedRegion.getHiddenModifiedRange(reader);
const items = this._modifiedOutlineSource.getBreadcrumbItems(range, reader);

if (items.length > 0) {
children.push($('span', undefined, '\u00a0|\u00a0'));
if (items.length > 0) {
children.push($('span', undefined, '\u00a0|\u00a0'));

let isFirst = true;
for (const item of items) {
if (!isFirst) {
children.push($('span', {}, ' ', renderIcon(Codicon.chevronRight), ' '));
}
let isFirst = true;
for (const item of items) {
if (!isFirst) {
children.push($('span', {}, ' ', renderIcon(Codicon.chevronRight), ' '));
}

const icon = SymbolKinds.toIcon(item.kind);
children.push($('span', {}, renderIcon(icon), ' ', item.name));
isFirst = false;
const icon = SymbolKinds.toIcon(item.kind);
children.push($('span', {}, renderIcon(icon), ' ', item.name));
isFirst = false;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5998,7 +5998,7 @@ declare namespace monaco.editor {
/**
* Get the vertical position (top offset) for the line's top w.r.t. to the first line.
*/
getTopForLineNumber(lineNumber: number): number;
getTopForLineNumber(lineNumber: number, includeViewZones?: boolean): number;
/**
* Get the vertical position (top offset) for the line's bottom w.r.t. to the first line.
*/
Expand Down