Implemented match case and whole wrd (#8904)

* Implemented match case and whole wrd

* removed unused ref

* renamed test method

* escape \

* refactored search

* added more tests

* updated tests appying match case and whole word to spcl characters

* regex update

* spcl to special

* non-capturing group added to the regex

* test
This commit is contained in:
Maddy
2020-01-23 07:28:12 -08:00
committed by GitHub
parent 76967d9467
commit 5ccc0fd97b
5 changed files with 146 additions and 39 deletions

View File

@@ -430,7 +430,7 @@ export interface INotebookFindModel {
findPrevious(): Promise<NotebookRange>;
/** search the notebook model for the given exp up to maxMatch occurances */
find(exp: string, maxMatches?: number): Promise<NotebookRange>;
find(exp: string, matchCase?: boolean, wholeWord?: boolean, maxMatches?: number): Promise<NotebookRange>;
/** clear the results of the find */
clearFind(): void;

View File

@@ -282,12 +282,12 @@ export class NotebookEditor extends BaseEditor implements IFindNotebookControlle
}
}
if (e.searchString) {
if (e.searchString || e.matchCase || e.wholeWord) {
this._findDecorations.clearDecorations();
if (this._notebookModel) {
if (this._findState.searchString) {
let findScope = this._findDecorations.getFindScope();
if (this._findState.searchString === this.notebookFindModel.findExpression && findScope !== null) {
if (this._findState.searchString === this.notebookFindModel.findExpression && findScope !== null && !e.matchCase && !e.wholeWord) {
if (findScope) {
this._updateFinderMatchState();
this._findState.changeMatchInfo(
@@ -300,7 +300,7 @@ export class NotebookEditor extends BaseEditor implements IFindNotebookControlle
} else {
this.notebookInput.notebookFindModel.clearDecorations();
this.notebookFindModel.findExpression = this._findState.searchString;
this.notebookInput.notebookFindModel.find(this._findState.searchString, NOTEBOOK_MAX_MATCHES).then(findRange => {
this.notebookInput.notebookFindModel.find(this._findState.searchString, this._findState.matchCase, this._findState.wholeWord, NOTEBOOK_MAX_MATCHES).then(findRange => {
if (findRange) {
this.updatePosition(findRange);
} else if (this.notebookFindModel.findMatches.length > 0) {