diff --git a/src/vs/editor/contrib/find/simpleFindWidget.css b/src/vs/editor/contrib/find/simpleFindWidget.css index 136970945a4b342efb9b39513832b037232171b8..39f5f0d3e6b0b748014db40f6c1966709b8cf1bf 100644 --- a/src/vs/editor/contrib/find/simpleFindWidget.css +++ b/src/vs/editor/contrib/find/simpleFindWidget.css @@ -78,7 +78,7 @@ background-image: url('images/close-dark.svg'); } -monaco-workbench .simple-find-part .button.disabled { +.monaco-workbench .simple-find-part .button.disabled { opacity: 0.3; cursor: default; } \ No newline at end of file diff --git a/src/vs/editor/contrib/find/simpleFindWidget.ts b/src/vs/editor/contrib/find/simpleFindWidget.ts index c7833dcc2532de9ab8108d1523dc8f928d35662d..f97cf3bdb1399116fe16b46d17642ce9f9faa003 100644 --- a/src/vs/editor/contrib/find/simpleFindWidget.ts +++ b/src/vs/editor/contrib/find/simpleFindWidget.ts @@ -33,6 +33,9 @@ export abstract class SimpleFindWidget extends Widget { private readonly _focusTracker: dom.IFocusTracker; private readonly _findInputFocusTracker: dom.IFocusTracker; private readonly _updateHistoryDelayer: Delayer; + private prevBtn: SimpleButton; + private nextBtn: SimpleButton; + private foundMatch: boolean; constructor( @IContextViewService private readonly _contextViewService: IContextViewService, @@ -54,6 +57,8 @@ export abstract class SimpleFindWidget extends Widget { new RegExp(value); return null; } catch (e) { + this.foundMatch = false; + this.updateBtns(); return { content: e.message }; } } @@ -63,7 +68,8 @@ export abstract class SimpleFindWidget extends Widget { this._updateHistoryDelayer = new Delayer(500); this.oninput(this._findInput.domNode, (e) => { - this.onInputChanged(); + this.foundMatch = this.onInputChanged(); + this.updateBtns(); this._delayedUpdateHistory(); }); @@ -99,7 +105,7 @@ export abstract class SimpleFindWidget extends Widget { } })); - const prevBtn = new SimpleButton({ + this.prevBtn = new SimpleButton({ label: NLS_PREVIOUS_MATCH_BTN_LABEL, className: 'previous', onTrigger: () => { @@ -107,7 +113,7 @@ export abstract class SimpleFindWidget extends Widget { } }); - const nextBtn = new SimpleButton({ + this.nextBtn = new SimpleButton({ label: NLS_NEXT_MATCH_BTN_LABEL, className: 'next', onTrigger: () => { @@ -126,8 +132,8 @@ export abstract class SimpleFindWidget extends Widget { this._innerDomNode = document.createElement('div'); this._innerDomNode.classList.add('simple-find-part'); this._innerDomNode.appendChild(this._findInput.domNode); - this._innerDomNode.appendChild(prevBtn.domNode); - this._innerDomNode.appendChild(nextBtn.domNode); + this._innerDomNode.appendChild(this.prevBtn.domNode); + this._innerDomNode.appendChild(this.nextBtn.domNode); this._innerDomNode.appendChild(closeBtn.domNode); // _domNode wraps _innerDomNode, ensuring that @@ -156,7 +162,7 @@ export abstract class SimpleFindWidget extends Widget { })); } - protected abstract onInputChanged(): void; + protected abstract onInputChanged(): boolean; protected abstract find(previous: boolean): void; protected abstract onFocusTrackerFocus(): void; protected abstract onFocusTrackerBlur(): void; @@ -213,6 +219,7 @@ export abstract class SimpleFindWidget extends Widget { } this._isVisible = true; + this.updateBtns(); setTimeout(() => { dom.addClass(this._innerDomNode, 'visible'); @@ -243,6 +250,7 @@ export abstract class SimpleFindWidget extends Widget { // Need to delay toggling visibility until after Transition, then visibility hidden - removes from tabIndex list setTimeout(() => { this._isVisible = false; + this.updateBtns(); dom.removeClass(this._innerDomNode, 'visible'); }, 200); } @@ -267,6 +275,12 @@ export abstract class SimpleFindWidget extends Widget { protected _getCaseSensitiveValue(): boolean { return this._findInput.getCaseSensitive(); } + + private updateBtns() { + let hasInput = this.inputValue.length > 0; + this.prevBtn.setEnabled(this._isVisible && hasInput && this.foundMatch); + this.nextBtn.setEnabled(this._isVisible && hasInput && this.foundMatch); + } } // theming diff --git a/src/vs/workbench/contrib/terminal/browser/terminalFindWidget.ts b/src/vs/workbench/contrib/terminal/browser/terminalFindWidget.ts index db30d122c39cb59f26f10c4dc829325f92683aed..75e51bcfa220ce12d3caf35bb95c89fc589fe16b 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalFindWidget.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalFindWidget.ts @@ -50,8 +50,9 @@ export class TerminalFindWidget extends SimpleFindWidget { // Ignore input changes for now const instance = this._terminalService.getActiveInstance(); if (instance !== null) { - instance.findNext(this.inputValue, { regex: this._getRegexValue(), wholeWord: this._getWholeWordValue(), caseSensitive: this._getCaseSensitiveValue(), incremental: true }); + return instance.findNext(this.inputValue, { regex: this._getRegexValue(), wholeWord: this._getWholeWordValue(), caseSensitive: this._getCaseSensitiveValue(), incremental: true }); } + return false; } protected onFocusTrackerFocus() { diff --git a/src/vs/workbench/contrib/webview/browser/webviewFindWidget.ts b/src/vs/workbench/contrib/webview/browser/webviewFindWidget.ts index e33b782bfa819205bd3a4858b8f561259850bf39..1f337cbc8e37be3a5f847fa36a7ea7883e9a3530 100644 --- a/src/vs/workbench/contrib/webview/browser/webviewFindWidget.ts +++ b/src/vs/workbench/contrib/webview/browser/webviewFindWidget.ts @@ -44,6 +44,7 @@ export class WebviewFindWidget extends SimpleFindWidget { } else { this._delegate.stopFind(false); } + return false; } protected onFocusTrackerFocus() { }