Skip to content

Commit ecbbe26

Browse files
authored
listeners for notebook replace input element (#247684)
* add replace listeners -- wip * guess what? typescript isn't an HDL. order matters smh
1 parent e665c52 commit ecbbe26

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.ts

+22-6
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
292292
private readonly _innerFindDomNode: HTMLElement;
293293
private readonly _focusTracker: dom.IFocusTracker;
294294
private readonly _findInputFocusTracker: dom.IFocusTracker;
295-
private readonly _updateHistoryDelayer: Delayer<void>;
295+
private readonly _updateFindHistoryDelayer: Delayer<void>;
296296
protected readonly _matchesCount!: HTMLElement;
297297
private readonly prevBtn: SimpleButton;
298298
private readonly nextBtn: SimpleButton;
@@ -301,6 +301,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
301301
private readonly _innerReplaceDomNode!: HTMLElement;
302302
private _toggleReplaceBtn!: SimpleButton;
303303
private readonly _replaceInputFocusTracker!: dom.IFocusTracker;
304+
private readonly _updateReplaceHistoryDelayer: Delayer<void>;
304305
protected _replaceBtn!: SimpleButton;
305306
protected _replaceAllBtn!: SimpleButton;
306307

@@ -427,12 +428,12 @@ export abstract class SimpleFindReplaceWidget extends Widget {
427428
));
428429

429430
// Find History with update delayer
430-
this._updateHistoryDelayer = new Delayer<void>(500);
431+
this._updateFindHistoryDelayer = new Delayer<void>(500);
431432

432433
this.oninput(this._findInput.domNode, (e) => {
433434
this.foundMatch = this.onInputChanged();
434435
this.updateButtons(this.foundMatch);
435-
this._delayedUpdateHistory();
436+
this._delayedUpdateFindHistory();
436437
});
437438

438439
this._register(this._findInput.inputBox.onDidChange(() => {
@@ -585,6 +586,13 @@ export abstract class SimpleFindReplaceWidget extends Widget {
585586
this._register(this._replaceInputFocusTracker.onDidFocus(this.onReplaceInputFocusTrackerFocus.bind(this)));
586587
this._register(this._replaceInputFocusTracker.onDidBlur(this.onReplaceInputFocusTrackerBlur.bind(this)));
587588

589+
// Replace History with update delayer
590+
this._updateReplaceHistoryDelayer = new Delayer<void>(500);
591+
592+
this.oninput(this._replaceInput.domNode, (e) => {
593+
this._delayedUpdateReplaceHistory();
594+
});
595+
588596
this._register(this._replaceInput.inputBox.onDidChange(() => {
589597
this._state.change({ replaceString: this._replaceInput.getValue() }, true);
590598
}));
@@ -875,14 +883,22 @@ export abstract class SimpleFindReplaceWidget extends Widget {
875883
}
876884
}
877885

878-
protected _delayedUpdateHistory() {
879-
this._updateHistoryDelayer.trigger(this._updateHistory.bind(this));
886+
protected _delayedUpdateFindHistory() {
887+
this._updateFindHistoryDelayer.trigger(this._updateFindHistory.bind(this));
880888
}
881889

882-
protected _updateHistory() {
890+
protected _updateFindHistory() {
883891
this._findInput.inputBox.addToHistory();
884892
}
885893

894+
protected _delayedUpdateReplaceHistory() {
895+
this._updateReplaceHistoryDelayer.trigger(this._updateReplaceHistory.bind(this));
896+
}
897+
898+
protected _updateReplaceHistory() {
899+
this._replaceInput.inputBox.addToHistory();
900+
}
901+
886902
protected _getRegexValue(): boolean {
887903
return this._findInput.getRegex();
888904
}

0 commit comments

Comments
 (0)