Fix/find context correction (#9949)

* trigger input change on new notebooks

* return to avoid further executions

* remove unnecessary check
This commit is contained in:
Maddy
2020-04-14 12:24:44 -07:00
committed by GitHub
parent fb1292426b
commit 0cdda5ed1b

View File

@@ -283,22 +283,22 @@ export class NotebookEditor extends BaseEditor implements IFindNotebookControlle
} else { } else {
this._finder.getDomNode().style.visibility = 'hidden'; this._finder.getDomNode().style.visibility = 'hidden';
this._findDecorations.clearDecorations(); this._findDecorations.clearDecorations();
return;
} }
} else { } else {
if (!this._findState.isRevealed) { if (!this._findState.isRevealed) {
this._finder.getDomNode().style.visibility = 'hidden'; this._finder.getDomNode().style.visibility = 'hidden';
this._findDecorations.clearDecorations(); this._findDecorations.clearDecorations();
return;
} }
} }
if (e.searchString || e.matchCase || e.wholeWord) { if (e.searchString || e.matchCase || e.wholeWord) {
this._findDecorations.clearDecorations(); this._findDecorations.clearDecorations();
// if the search scope changes remove the prev // if the search scope changes remove the prev
if (this._notebookModel) { if (this._notebookModel && this._findState.searchString) {
if (this._findState.searchString) {
let findScope = this._findDecorations.getFindScope(); let findScope = this._findDecorations.getFindScope();
if (this._findState.searchString === this.notebookFindModel.findExpression && findScope !== null && !e.matchCase && !e.wholeWord && !e.searchScope) { if (this._findState.searchString === this.notebookFindModel.findExpression && findScope && !e.matchCase && !e.wholeWord && !e.searchScope) {
if (findScope) {
this._updateFinderMatchState(); this._updateFinderMatchState();
this._findState.changeMatchInfo( this._findState.changeMatchInfo(
this.notebookFindModel.getFindIndex(), this.notebookFindModel.getFindIndex(),
@@ -306,7 +306,6 @@ export class NotebookEditor extends BaseEditor implements IFindNotebookControlle
this._currentMatch this._currentMatch
); );
this._setCurrentFindMatch(findScope); this._setCurrentFindMatch(findScope);
}
} else { } else {
this.notebookInput.notebookFindModel.clearDecorations(); this.notebookInput.notebookFindModel.clearDecorations();
this.notebookFindModel.findExpression = this._findState.searchString; this.notebookFindModel.findExpression = this._findState.searchString;
@@ -336,7 +335,6 @@ export class NotebookEditor extends BaseEditor implements IFindNotebookControlle
this.notebookFindModel.clearFind(); this.notebookFindModel.clearFind();
} }
} }
}
if (e.searchScope) { if (e.searchScope) {
await this.notebookInput.notebookFindModel.find(this._findState.searchString, this._findState.matchCase, this._findState.wholeWord, NOTEBOOK_MAX_MATCHES).then(findRange => { await this.notebookInput.notebookFindModel.find(this._findState.searchString, this._findState.matchCase, this._findState.wholeWord, NOTEBOOK_MAX_MATCHES).then(findRange => {
this._findDecorations.set(this.notebookFindModel.findMatches, this._currentMatch); this._findDecorations.set(this.notebookFindModel.findMatches, this._currentMatch);
@@ -377,6 +375,11 @@ export class NotebookEditor extends BaseEditor implements IFindNotebookControlle
this._register(this._notebookModel.contentChanged(e => { this._register(this._notebookModel.contentChanged(e => {
this._onFindStateChange(changeEvent).catch(onUnexpectedError); this._onFindStateChange(changeEvent).catch(onUnexpectedError);
})); }));
this._register(this._notebookService.onNotebookEditorAdd(async (e) => {
// wait for the model to be ready and trigger input change
await e.modelReady;
this._triggerInputChange();
}));
} }
public setSelection(range: NotebookRange): void { public setSelection(range: NotebookRange): void {