Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 committed May 18, 2023
1 parent de78d5e commit 393d160
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"xterm": "5.2.0-beta.41",
"xterm-addon-canvas": "0.4.0-beta.11",
"xterm-addon-image": "0.4.0",
"xterm-addon-search": "0.11.0",
"xterm-addon-search": "0.12.0-beta.3",
"xterm-addon-serialize": "0.9.0",
"xterm-addon-unicode11": "0.5.0",
"xterm-addon-webgl": "0.15.0-beta.10",
Expand Down
2 changes: 1 addition & 1 deletion remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"xterm": "5.2.0-beta.41",
"xterm-addon-canvas": "0.4.0-beta.11",
"xterm-addon-image": "0.4.0",
"xterm-addon-search": "0.11.0",
"xterm-addon-search": "0.12.0-beta.3",
"xterm-addon-serialize": "0.9.0",
"xterm-addon-unicode11": "0.5.0",
"xterm-addon-webgl": "0.15.0-beta.10",
Expand Down
2 changes: 1 addition & 1 deletion remote/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"xterm": "5.2.0-beta.41",
"xterm-addon-canvas": "0.4.0-beta.11",
"xterm-addon-image": "0.4.0",
"xterm-addon-search": "0.11.0",
"xterm-addon-search": "0.12.0-beta.3",
"xterm-addon-unicode11": "0.5.0",
"xterm-addon-webgl": "0.15.0-beta.10"
}
Expand Down
8 changes: 4 additions & 4 deletions remote/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ xterm-addon-image@0.4.0:
resolved "https://registry.yarnpkg.com/xterm-addon-image/-/xterm-addon-image-0.4.0.tgz#36e98fa892db11755a5f6e9654f924e876e29bf8"
integrity sha512-3wumCJo4WTzxvecSMxJ7XtpVQeFe4gE2cdHCyUdo7zagVkS18YXJacGx6DjlAIccdJn6/LhGuD99xOSSvYx9Gw==

xterm-addon-search@0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.11.0.tgz#2a00ff7f9848f6140e7c4d1782486b0b18b06e0d"
integrity sha512-6U4uHXcQ7G5igsdaGqrJ9ehm7vep24bXqWxuy3AnIosXF2Z5uy2MvmYRyTGNembIqPV/x1YhBQ7uShtuqBHhOQ==
xterm-addon-search@0.12.0-beta.3:
version "0.12.0-beta.3"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.12.0-beta.3.tgz#9ced9431378d37f4b42010691eb5b76f66b8b9e5"
integrity sha512-NgzmUP5/764+csltcteHvIoNOScQHkIXkwEj+KgQr4QR48qFZMq3iGybcvv6icJsGglvvdG7YRputyT35eCjpQ==

xterm-addon-unicode11@0.5.0:
version "0.5.0"
Expand Down
8 changes: 4 additions & 4 deletions remote/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -846,10 +846,10 @@ xterm-addon-image@0.4.0:
resolved "https://registry.yarnpkg.com/xterm-addon-image/-/xterm-addon-image-0.4.0.tgz#36e98fa892db11755a5f6e9654f924e876e29bf8"
integrity sha512-3wumCJo4WTzxvecSMxJ7XtpVQeFe4gE2cdHCyUdo7zagVkS18YXJacGx6DjlAIccdJn6/LhGuD99xOSSvYx9Gw==

xterm-addon-search@0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.11.0.tgz#2a00ff7f9848f6140e7c4d1782486b0b18b06e0d"
integrity sha512-6U4uHXcQ7G5igsdaGqrJ9ehm7vep24bXqWxuy3AnIosXF2Z5uy2MvmYRyTGNembIqPV/x1YhBQ7uShtuqBHhOQ==
xterm-addon-search@0.12.0-beta.3:
version "0.12.0-beta.3"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.12.0-beta.3.tgz#9ced9431378d37f4b42010691eb5b76f66b8b9e5"
integrity sha512-NgzmUP5/764+csltcteHvIoNOScQHkIXkwEj+KgQr4QR48qFZMq3iGybcvv6icJsGglvvdG7YRputyT35eCjpQ==

xterm-addon-serialize@0.9.0:
version "0.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
border: 1px solid var(--vscode-contrastBorder);
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
font-size: 12px;
}

.monaco-workbench.reduce-motion .monaco-editor .find-widget {
Expand All @@ -57,9 +58,9 @@
}

.monaco-workbench .simple-find-part .matchesCount {
width: 68px;
max-width: 68px;
min-width: 68px;
width: 73px;
max-width: 73px;
min-width: 73px;
padding-left: 5px;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface IFindOptions {
}

const SIMPLE_FIND_WIDGET_INITIAL_WIDTH = 310;
const MATCHES_COUNT_WIDTH = 68;
const MATCHES_COUNT_WIDTH = 73;

export abstract class SimpleFindWidget extends Widget {
private readonly _findInput: FindInput;
Expand Down Expand Up @@ -208,6 +208,10 @@ export abstract class SimpleFindWidget extends Widget {
protected abstract _onFindInputFocusTrackerBlur(): void;
protected abstract _getResultCount(): Promise<{ resultIndex: number; resultCount: number } | undefined>;

protected get _matchesLimit(): number {
return Number.MAX_SAFE_INTEGER;
}

protected get inputValue() {
return this._findInput.getValue();
}
Expand Down Expand Up @@ -251,7 +255,7 @@ export abstract class SimpleFindWidget extends Widget {
}

this._isVisible = true;
this.updateButtons(this._foundMatch);
this.updateResultCount();
this.layout();

setTimeout(() => {
Expand Down Expand Up @@ -354,15 +358,21 @@ export abstract class SimpleFindWidget extends Widget {

const count = await this._getResultCount();
this._matchesCount.innerText = '';
const showRedOutline = (this.inputValue.length > 0 && count?.resultCount === 0);
this._matchesCount.classList.toggle('no-results', showRedOutline);
let label = '';
this._matchesCount.classList.toggle('no-results', false);
if (count?.resultCount !== undefined && count?.resultCount === 0) {
label = NLS_NO_RESULTS;
if (!!this.inputValue) {
this._matchesCount.classList.toggle('no-results', true);
if (count?.resultCount) {
let matchesCount: string = String(count.resultCount);
if (count.resultCount >= this._matchesLimit) {
matchesCount += '+';
}
let matchesPosition: string = String(count.resultIndex + 1);
if (matchesPosition === '0') {
matchesPosition = '?';
}
} else if (count?.resultCount) {
label = strings.format(NLS_MATCHES_LOCATION, count.resultIndex + 1, count?.resultCount);
label = strings.format(NLS_MATCHES_LOCATION, matchesPosition, matchesCount);
} else {
label = NLS_NO_RESULTS;
}
alertFn(this._announceSearchResults(label, this.inputValue));
this._matchesCount.appendChild(document.createTextNode(label));
Expand Down
6 changes: 5 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,10 @@ export interface ITerminalChildElement {
xtermReady?(xterm: IXtermTerminal): void;
}

export const enum XtermTerminalConstants {
SearchHighlightLimit = 1000
}

export interface IXtermTerminal {
/**
* An object that tracks when commands are run and enables navigating and selecting between
Expand All @@ -969,7 +973,7 @@ export interface IXtermTerminal {
readonly shellIntegration: IShellIntegration;

readonly onDidChangeSelection: Event<void>;
readonly onDidChangeFindResults: Event<{ resultIndex: number; resultCount: number } | undefined>;
readonly onDidChangeFindResults: Event<{ resultIndex: number; resultCount: number }>;

/**
* Gets a view of the current texture atlas used by the renderers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IShellIntegration, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
import { ITerminalFont } from 'vs/workbench/contrib/terminal/common/terminal';
import { isSafari } from 'vs/base/browser/browser';
import { IMarkTracker, IInternalXtermTerminal, IXtermTerminal, ISuggestController, IXtermColorProvider } from 'vs/workbench/contrib/terminal/browser/terminal';
import { IMarkTracker, IInternalXtermTerminal, IXtermTerminal, ISuggestController, IXtermColorProvider, XtermTerminalConstants } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ILogService } from 'vs/platform/log/common/log';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { TerminalStorageKeys } from 'vs/workbench/contrib/terminal/common/terminalStorageKeys';
Expand Down Expand Up @@ -152,7 +152,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
readonly onDidRequestSendText = this._onDidRequestSendText.event;
private readonly _onDidRequestFreePort = new Emitter<string>();
readonly onDidRequestFreePort = this._onDidRequestFreePort.event;
private readonly _onDidChangeFindResults = new Emitter<{ resultIndex: number; resultCount: number } | undefined>();
private readonly _onDidChangeFindResults = new Emitter<{ resultIndex: number; resultCount: number }>();
readonly onDidChangeFindResults = this._onDidChangeFindResults.event;
private readonly _onDidChangeSelection = new Emitter<void>();
readonly onDidChangeSelection = this._onDidChangeSelection.event;
Expand Down Expand Up @@ -409,9 +409,9 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
return this._searchAddon;
}
const AddonCtor = await this._getSearchAddonConstructor();
this._searchAddon = new AddonCtor();
this._searchAddon = new AddonCtor({ highlightLimit: XtermTerminalConstants.SearchHighlightLimit });
this.raw.loadAddon(this._searchAddon);
this._searchAddon.onDidChangeResults((results: { resultIndex: number; resultCount: number } | undefined) => {
this._searchAddon.onDidChangeResults((results: { resultIndex: number; resultCount: number }) => {
this._lastFindResult = results;
this._onDidChangeFindResults.fire(results);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { SimpleFindWidget } from 'vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { ITerminalInstance, IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ITerminalInstance, IXtermTerminal, XtermTerminalConstants } from 'vs/workbench/contrib/terminal/browser/terminal';
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
Expand All @@ -19,6 +19,8 @@ export class TerminalFindWidget extends SimpleFindWidget {
private _findWidgetFocused: IContextKey<boolean>;
private _findWidgetVisible: IContextKey<boolean>;

override get _matchesLimit() { return XtermTerminalConstants.SearchHighlightLimit; }

constructor(
private _instance: ITerminalInstance,
@IContextViewService _contextViewService: IContextViewService,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10463,10 +10463,10 @@ xterm-addon-image@0.4.0:
resolved "https://registry.yarnpkg.com/xterm-addon-image/-/xterm-addon-image-0.4.0.tgz#36e98fa892db11755a5f6e9654f924e876e29bf8"
integrity sha512-3wumCJo4WTzxvecSMxJ7XtpVQeFe4gE2cdHCyUdo7zagVkS18YXJacGx6DjlAIccdJn6/LhGuD99xOSSvYx9Gw==

xterm-addon-search@0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.11.0.tgz#2a00ff7f9848f6140e7c4d1782486b0b18b06e0d"
integrity sha512-6U4uHXcQ7G5igsdaGqrJ9ehm7vep24bXqWxuy3AnIosXF2Z5uy2MvmYRyTGNembIqPV/x1YhBQ7uShtuqBHhOQ==
xterm-addon-search@0.12.0-beta.3:
version "0.12.0-beta.3"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.12.0-beta.3.tgz#9ced9431378d37f4b42010691eb5b76f66b8b9e5"
integrity sha512-NgzmUP5/764+csltcteHvIoNOScQHkIXkwEj+KgQr4QR48qFZMq3iGybcvv6icJsGglvvdG7YRputyT35eCjpQ==

xterm-addon-serialize@0.9.0:
version "0.9.0"
Expand Down

0 comments on commit 393d160

Please sign in to comment.