-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add whole-word matching option in search bar (#13777)
* Implement whole-word matching option * Update Playwright Snapshots Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ce655d9
commit 31886fd
Showing
16 changed files
with
174 additions
and
6 deletions.
There are no files selected for viewing
Binary file modified
BIN
+216 Bytes
(100%)
.../jupyterlab/notebook-replace.test.ts-snapshots/replace-all-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+204 Bytes
(100%)
...yterlab/notebook-replace.test.ts-snapshots/replace-in-cell-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-17 Bytes
(100%)
...notebook-search.test.ts-snapshots/highlight-next-in-editor-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+198 Bytes
(100%)
...tebook-search.test.ts-snapshots/highlight-previous-element-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+8 Bytes
(100%)
...notebook-search.test.ts-snapshots/search-in-selected-cells-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+15 Bytes
(100%)
...a/test/jupyterlab/notebook-search.test.ts-snapshots/search-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+39 Bytes
(100%)
...b/notebook-search.test.ts-snapshots/search-on-deleted-cell-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+123 Bytes
(100%)
...erlab/notebook-search.test.ts-snapshots/search-on-new-cell-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-330 Bytes
(99%)
...ab/notebook-search.test.ts-snapshots/search-within-outputs-jupyterlab-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
import { | ||
GenericSearchProvider, | ||
SearchDocumentModel | ||
} from '@jupyterlab/documentsearch'; | ||
import { Widget } from '@lumino/widgets'; | ||
import { PromiseDelegate } from '@lumino/coreutils'; | ||
|
||
class LogSearchProvider extends GenericSearchProvider { | ||
private _queryReceived: PromiseDelegate<RegExp | null>; | ||
|
||
constructor(widget: Widget) { | ||
super(widget); | ||
this._queryReceived = new PromiseDelegate(); | ||
} | ||
get queryReceived(): Promise<RegExp | null> { | ||
return this._queryReceived.promise; | ||
} | ||
|
||
async startQuery(query: RegExp | null, filters = {}): Promise<void> { | ||
this._queryReceived.resolve(query); | ||
this._queryReceived = new PromiseDelegate(); | ||
} | ||
} | ||
|
||
describe('documentsearch/searchmodel', () => { | ||
describe('SearchDocumentModel', () => { | ||
let provider: LogSearchProvider; | ||
let widget: Widget; | ||
let model: SearchDocumentModel; | ||
|
||
beforeEach(() => { | ||
widget = new Widget(); | ||
provider = new LogSearchProvider(widget); | ||
model = new SearchDocumentModel(provider, 0); | ||
}); | ||
|
||
afterEach(async () => { | ||
widget.dispose(); | ||
}); | ||
|
||
describe('#searchExpression', () => { | ||
it('should notify provider of new query when set', async () => { | ||
model.searchExpression = 'query'; | ||
expect(model.searchExpression).toEqual('query'); | ||
const query = (await provider.queryReceived)!; | ||
expect(query.test('query')).toEqual(true); | ||
query.lastIndex = 0; | ||
expect(query.test('test')).toEqual(false); | ||
query.lastIndex = 0; | ||
}); | ||
}); | ||
|
||
describe('#caseSensitive', () => { | ||
it('should start a case-sensitive query', async () => { | ||
model.searchExpression = 'query'; | ||
model.caseSensitive = true; | ||
expect(model.caseSensitive).toEqual(true); | ||
let query = (await provider.queryReceived)!; | ||
expect(query.test('query')).toEqual(true); | ||
query.lastIndex = 0; | ||
expect(query.test('QUERY')).toEqual(false); | ||
query.lastIndex = 0; | ||
|
||
model.caseSensitive = false; | ||
expect(model.caseSensitive).toEqual(false); | ||
query = (await provider.queryReceived)!; | ||
expect(query.test('query')).toEqual(true); | ||
query.lastIndex = 0; | ||
expect(query.test('QUERY')).toEqual(true); | ||
query.lastIndex = 0; | ||
}); | ||
}); | ||
|
||
describe('#wholeWords', () => { | ||
it('should start a whole-words query', async () => { | ||
model.searchExpression = 'query'; | ||
model.wholeWords = true; | ||
expect(model.wholeWords).toEqual(true); | ||
let query = (await provider.queryReceived)!; | ||
expect(query.test(' query ')).toEqual(true); | ||
query.lastIndex = 0; | ||
expect(query.test('XqueryX')).toEqual(false); | ||
query.lastIndex = 0; | ||
|
||
model.wholeWords = false; | ||
expect(model.wholeWords).toEqual(false); | ||
query = (await provider.queryReceived)!; | ||
expect(query.test(' query ')).toEqual(true); | ||
query.lastIndex = 0; | ||
expect(query.test('XqueryX')).toEqual(true); | ||
query.lastIndex = 0; | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.