Skip to content

Commit

Permalink
Rebase against the upstream cd1af5b
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: cd1af5b
  • Loading branch information
Eclipse Che Sync committed Aug 4, 2023
2 parents 7f01efd + cd1af5b commit 7d82717
Show file tree
Hide file tree
Showing 17 changed files with 250 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ export class ViewZoneManager extends Disposable {

this._register(this._editors.original.onDidChangeViewZones((_args) => { if (!isChangingViewZones && !this._canIgnoreViewZoneUpdateEvent()) { updateImmediately.schedule(); } }));
this._register(this._editors.modified.onDidChangeViewZones((_args) => { if (!isChangingViewZones && !this._canIgnoreViewZoneUpdateEvent()) { updateImmediately.schedule(); } }));
this._register(this._editors.original.onDidChangeConfiguration((args) => { if (args.hasChanged(EditorOption.wrappingInfo)) { updateImmediately.schedule(); } }));
this._register(this._editors.modified.onDidChangeConfiguration((args) => { if (args.hasChanged(EditorOption.wrappingInfo)) { updateImmediately.schedule(); } }));
this._register(this._editors.original.onDidChangeConfiguration((args) => {
if (args.hasChanged(EditorOption.wrappingInfo) || args.hasChanged(EditorOption.lineHeight)) { updateImmediately.schedule(); }
}));
this._register(this._editors.modified.onDidChangeConfiguration((args) => {
if (args.hasChanged(EditorOption.wrappingInfo) || args.hasChanged(EditorOption.lineHeight)) { updateImmediately.schedule(); }
}));

const originalModelTokenizationCompleted = this._diffModel.map(m =>
m ? observableFromEvent(m.model.original.onDidChangeTokens, () => m.model.original.tokenization.backgroundTokenizationState === BackgroundTokenizationState.Completed) : undefined
Expand All @@ -87,7 +91,14 @@ export class ViewZoneManager extends Disposable {
state.read(reader);
const renderSideBySide = this._options.renderSideBySide.read(reader);
const innerHunkAlignment = renderSideBySide;
return computeRangeAlignment(this._editors.original, this._editors.modified, diff.mappings, alignmentViewZoneIdsOrig, alignmentViewZoneIdsMod, innerHunkAlignment);
return computeRangeAlignment(
this._editors.original,
this._editors.modified,
diff.mappings,
alignmentViewZoneIdsOrig,
alignmentViewZoneIdsMod,
innerHunkAlignment
);
});

const alignmentsSyncedMovedText = derived<ILineRangeAlignment[] | null>((reader) => {
Expand All @@ -97,7 +108,14 @@ export class ViewZoneManager extends Disposable {
state.read(reader);
const mappings = syncedMovedText.changes.map(c => new DiffMapping(c));
// TODO dont include alignments outside syncedMovedText
return computeRangeAlignment(this._editors.original, this._editors.modified, mappings, alignmentViewZoneIdsOrig, alignmentViewZoneIdsMod, true);
return computeRangeAlignment(
this._editors.original,
this._editors.modified,
mappings,
alignmentViewZoneIdsOrig,
alignmentViewZoneIdsMod,
true
);
});

function createFakeLinesDiv(): HTMLElement {
Expand Down
7 changes: 7 additions & 0 deletions code/src/vs/editor/common/diff/algorithms/diffAlgorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ export interface ISequence {
* Must not be negative.
*/
getBoundaryScore?(length: number): number;

/**
* For line sequences, getElement returns a number representing trimmed lines.
* This however checks equality for the original lines.
* It prevents shifting to less matching lines.
*/
isStronglyEqual(offset1: number, offset2: number): boolean;
}

export interface ITimeout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ function shiftDiffToBetterPosition(diff: SequenceDiff, sequence1: ISequence, seq
while (
diff.seq1Range.start - deltaBefore >= seq1ValidRange.start &&
diff.seq2Range.start - deltaBefore >= seq2ValidRange.start &&
sequence2.getElement(diff.seq2Range.start - deltaBefore) ===
sequence2.getElement(diff.seq2Range.endExclusive - deltaBefore) && deltaBefore < maxShiftLimit
sequence2.isStronglyEqual(diff.seq2Range.start - deltaBefore, diff.seq2Range.endExclusive - deltaBefore) && deltaBefore < maxShiftLimit
) {
deltaBefore++;
}
Expand All @@ -304,8 +303,7 @@ function shiftDiffToBetterPosition(diff: SequenceDiff, sequence1: ISequence, seq
while (
diff.seq1Range.start + deltaAfter < seq1ValidRange.endExclusive &&
diff.seq2Range.endExclusive + deltaAfter < seq2ValidRange.endExclusive &&
sequence2.getElement(diff.seq2Range.start + deltaAfter) ===
sequence2.getElement(diff.seq2Range.endExclusive + deltaAfter) && deltaAfter < maxShiftLimit
sequence2.isStronglyEqual(diff.seq2Range.start + deltaAfter, diff.seq2Range.endExclusive + deltaAfter) && deltaAfter < maxShiftLimit
) {
deltaAfter++;
}
Expand Down
8 changes: 8 additions & 0 deletions code/src/vs/editor/common/diff/standardLinesDiffComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,10 @@ export class LineSequence implements ISequence {
getText(range: OffsetRange): string {
return this.lines.slice(range.start, range.endExclusive).join('\n');
}

isStronglyEqual(offset1: number, offset2: number): boolean {
return this.lines[offset1] === this.lines[offset2];
}
}

function getIndentation(str: string): number {
Expand Down Expand Up @@ -800,6 +804,10 @@ export class LinesSliceCharSequence implements ISequence {
public countLinesIn(range: OffsetRange): number {
return this.translateOffset(range.endExclusive).lineNumber - this.translateOffset(range.start).lineNumber;
}

isStronglyEqual(offset1: number, offset2: number): boolean {
return this.elements[offset1] === this.elements[offset2];
}
}

function isWordChar(charCode: number): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
]
},
{
"originalRange": "[86,99)",
"modifiedRange": "[88,102)",
"originalRange": "[86,95)",
"modifiedRange": "[88,98)",
"innerChanges": [
{
"originalRange": "[86,1 -> 86,1]",
Expand Down Expand Up @@ -108,23 +108,7 @@
},
{
"originalRange": "[95,1 -> 95,1]",
"modifiedRange": "[97,1 -> 97,2]"
},
{
"originalRange": "[96,1 -> 96,1]",
"modifiedRange": "[98,1 -> 98,2]"
},
{
"originalRange": "[97,1 -> 97,1]",
"modifiedRange": "[99,1 -> 99,2]"
},
{
"originalRange": "[98,1 -> 98,1]",
"modifiedRange": "[100,1 -> 100,2]"
},
{
"originalRange": "[99,1 -> 99,1]",
"modifiedRange": "[101,1 -> 102,1]"
"modifiedRange": "[97,1 -> 98,1]"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
]
},
{
"originalRange": "[12,24)",
"modifiedRange": "[13,26)",
"originalRange": "[12,23)",
"modifiedRange": "[13,25)",
"innerChanges": [
{
"originalRange": "[12,1 -> 12,1]",
Expand Down Expand Up @@ -76,11 +76,7 @@
},
{
"originalRange": "[23,1 -> 23,1]",
"modifiedRange": "[24,1 -> 24,2]"
},
{
"originalRange": "[24,1 -> 24,1]",
"modifiedRange": "[25,1 -> 26,1]"
"modifiedRange": "[24,1 -> 25,1]"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"diffs": [
{
"originalRange": "[26,33)",
"modifiedRange": "[26,43)",
"originalRange": "[26,32)",
"modifiedRange": "[26,42)",
"innerChanges": [
{
"originalRange": "[26,10 -> 26,10]",
Expand Down Expand Up @@ -38,11 +38,7 @@
},
{
"originalRange": "[32,1 -> 32,1]",
"modifiedRange": "[41,1 -> 41,2]"
},
{
"originalRange": "[33,1 -> 33,1]",
"modifiedRange": "[42,1 -> 43,1]"
"modifiedRange": "[41,1 -> 42,1]"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ class AccessibleViewSymbolQuickPick {
quickPick.onDidAccept(() => {
this._accessibleView.showSymbol(provider, quickPick.selectedItems[0]);
});
quickPick.onDidHide(() => {
if (quickPick.selectedItems.length === 0) {
// this was escaped, so refocus the accessible view
this._accessibleView.show(provider);
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,26 @@ export class UnfocusedViewDimmingContribution extends Disposable implements IWor
opacity = clamp(opacityConfig, 0.2, 1);
}

const rules = new Set<string>();
let cssTextContent = '';

// Only add the styles if the feature is used
if (opacity !== 1) {
const filterRule = `filter: opacity(${opacity});`;
// Terminal tabs
rules.add(`.monaco-workbench .pane-body.integrated-terminal:not(:focus-within) .tabs-container { ${filterRule} }`);
// Terminals
rules.add(`.monaco-workbench .pane-body.integrated-terminal .xterm:not(.focus) { ${filterRule} }`);
// Editors
rules.add(`.monaco-workbench .editor-instance:not(:focus-within) .monaco-editor { ${filterRule} }`);
const rules = new Set<string>();
if (opacity !== 1) {
const filterRule = `filter: opacity(${opacity});`;
// Terminal tabs
rules.add(`.monaco-workbench .pane-body.integrated-terminal:not(:focus-within) .tabs-container { ${filterRule} }`);
// Terminals
rules.add(`.monaco-workbench .pane-body.integrated-terminal .terminal-wrapper:not(:focus-within) { ${filterRule} }`);
// Text editors
rules.add(`.monaco-workbench .editor-instance:not(:focus-within) .monaco-editor { ${filterRule} }`);
// Terminal editors
rules.add(`.monaco-workbench .editor-instance:not(:focus-within) .terminal-wrapper { ${filterRule} }`);
}
cssTextContent = [...rules].join('\n');
}

elStyle.textContent = [...rules].join('\n');
elStyle.textContent = cssTextContent;
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,14 @@ div.simple-find-part-wrapper div.button:hover:not(.disabled) {
outline: 1px dashed var(--vscode-toolbar-hoverOutline);
outline-offset: -1px;
}

.monaco-workbench .simple-find-part .monaco-sash {
left: 0 !important;
border-left: 1px solid;
border-bottom-left-radius: 4px;
}

.monaco-workbench .simple-find-part .monaco-sash.vertical:before{
width: 2px;
left: calc(50% - (var(--vscode-sash-hover-size) / 4));
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { ContextScopedFindInput } from 'vs/platform/history/browser/contextScopedHistoryWidget';
import { widgetClose } from 'vs/platform/theme/common/iconRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import * as strings from 'vs/base/common/strings';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { showHistoryKeybindingHint } from 'vs/platform/history/browser/historyWidgetKeybindingHint';
import { status } from 'vs/base/browser/ui/aria/aria';
import { defaultInputBoxStyles, defaultToggleStyles } from 'vs/platform/theme/browser/defaultStyles';
import { ISashEvent, IVerticalSashLayoutProvider, Orientation, Sash } from 'vs/base/browser/ui/sash/sash';
import { registerColor } from 'vs/platform/theme/common/colorRegistry';

const NLS_FIND_INPUT_LABEL = nls.localize('label.find', "Find");
const NLS_FIND_INPUT_PLACEHOLDER = nls.localize('placeholder.find', "Find (\u21C5 for history)");
Expand All @@ -41,12 +44,14 @@ interface IFindOptions {
closeWidgetActionId?: string;
matchesLimit?: number;
type?: 'Terminal' | 'Webview';
initialWidth?: number;
enableSash?: boolean;
}

const SIMPLE_FIND_WIDGET_INITIAL_WIDTH = 310;
const MATCHES_COUNT_WIDTH = 73;

export abstract class SimpleFindWidget extends Widget {
export abstract class SimpleFindWidget extends Widget implements IVerticalSashLayoutProvider {
private readonly _findInput: FindInput;
private readonly _domNode: HTMLElement;
private readonly _innerDomNode: HTMLElement;
Expand Down Expand Up @@ -203,6 +208,44 @@ export abstract class SimpleFindWidget extends Widget {
this._delayedUpdateHistory();
}));
}

let initialMinWidth = options?.initialWidth;
if (initialMinWidth) {
initialMinWidth = initialMinWidth < SIMPLE_FIND_WIDGET_INITIAL_WIDTH ? SIMPLE_FIND_WIDGET_INITIAL_WIDTH : initialMinWidth;
this._domNode.style.width = `${initialMinWidth}px`;
}

if (options?.enableSash) {
const _initialMinWidth = initialMinWidth ?? SIMPLE_FIND_WIDGET_INITIAL_WIDTH;
let originalWidth = _initialMinWidth;

// sash
const resizeSash = new Sash(this._innerDomNode, this, { orientation: Orientation.VERTICAL, size: 1 });
this._register(resizeSash.onDidStart(() => {
originalWidth = parseFloat(dom.getComputedStyle(this._domNode).width);
}));

this._register(resizeSash.onDidChange((e: ISashEvent) => {
const width = originalWidth + e.startX - e.currentX;
if (width < _initialMinWidth) {
return;
}
this._domNode.style.width = `${width}px`;
}));

this._register(resizeSash.onDidReset(e => {
const currentWidth = parseFloat(dom.getComputedStyle(this._domNode).width);
if (currentWidth === _initialMinWidth) {
this._domNode.style.width = '100%';
} else {
this._domNode.style.width = `${_initialMinWidth}px`;
}
}));
}
}

public getVerticalSashLeft(_sash: Sash): number {
return 0;
}

public abstract find(previous: boolean): void;
Expand Down Expand Up @@ -399,3 +442,10 @@ export abstract class SimpleFindWidget extends Widget {
return nls.localize('ariaSearchNoResultWithLineNumNoCurrentMatch', "{0} found for '{1}'", label, searchString);
}
}

export const simpleFindWidgetSashBorder = registerColor('simpleFindWidget.sashBorder', { dark: '#454545', light: '#C8C8C8', hcDark: '#6FC3DF', hcLight: '#0F4A85' }, nls.localize('simpleFindWidget.sashBorder', 'Border color of the sash border.'));

registerThemingParticipant((theme, collector) => {
const resizeBorderBackground = theme.getColor(simpleFindWidgetSashBorder);
collector.addRule(`.monaco-workbench .simple-find-part .monaco-sash { background-color: ${resizeBorderBackground}; border-color: ${resizeBorderBackground} }`);
});
Loading

0 comments on commit 7d82717

Please sign in to comment.