未验证 提交 d28a7fd5 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #73692 from Urange/master

Potential fix for issue #73396
......@@ -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
......@@ -33,6 +33,9 @@ export abstract class SimpleFindWidget extends Widget {
private readonly _focusTracker: dom.IFocusTracker;
private readonly _findInputFocusTracker: dom.IFocusTracker;
private readonly _updateHistoryDelayer: Delayer<void>;
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.updateButtons();
return { content: e.message };
}
}
......@@ -63,7 +68,8 @@ export abstract class SimpleFindWidget extends Widget {
this._updateHistoryDelayer = new Delayer<void>(500);
this.oninput(this._findInput.domNode, (e) => {
this.onInputChanged();
this.foundMatch = this.onInputChanged();
this.updateButtons();
this._delayedUpdateHistory();
});
......@@ -99,7 +105,7 @@ export abstract class SimpleFindWidget extends Widget {
}
}));
const prevBtn = this._register(new SimpleButton({
this.prevBtn = this._register(new SimpleButton({
label: NLS_PREVIOUS_MATCH_BTN_LABEL,
className: 'previous',
onTrigger: () => {
......@@ -107,7 +113,7 @@ export abstract class SimpleFindWidget extends Widget {
}
}));
const nextBtn = this._register(new SimpleButton({
this.nextBtn = this._register(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.updateButtons();
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.updateButtons();
dom.removeClass(this._innerDomNode, 'visible');
}, 200);
}
......@@ -267,6 +275,12 @@ export abstract class SimpleFindWidget extends Widget {
protected _getCaseSensitiveValue(): boolean {
return this._findInput.getCaseSensitive();
}
private updateButtons() {
let hasInput = this.inputValue.length > 0;
this.prevBtn.setEnabled(this._isVisible && hasInput && this.foundMatch);
this.nextBtn.setEnabled(this._isVisible && hasInput && this.foundMatch);
}
}
// theming
......
......@@ -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() {
......
......@@ -44,6 +44,7 @@ export class WebviewFindWidget extends SimpleFindWidget {
} else {
this._delegate.stopFind(false);
}
return false;
}
protected onFocusTrackerFocus() { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册