Skip to content

Commit

Permalink
Merge pull request #7258 from mlucool/output-search
Browse files Browse the repository at this point in the history
Support for output search
  • Loading branch information
saulshanabrook committed Dec 24, 2019
2 parents 023828a + ee1f1d0 commit 37c7a64
Show file tree
Hide file tree
Showing 8 changed files with 791 additions and 68 deletions.
1 change: 1 addition & 0 deletions packages/documentsearch/package.json
Expand Up @@ -38,6 +38,7 @@
"@jupyterlab/codemirror": "^2.0.0-alpha.4",
"@jupyterlab/fileeditor": "^2.0.0-alpha.4",
"@jupyterlab/notebook": "^2.0.0-alpha.4",
"@lumino/algorithm": "^1.2.1",
"@lumino/coreutils": "^1.4.0",
"@lumino/disposable": "^1.3.2",
"@lumino/polling": "^1.0.1",
Expand Down
27 changes: 26 additions & 1 deletion packages/documentsearch/src/interfaces.ts
Expand Up @@ -4,6 +4,10 @@
import { ISignal } from '@lumino/signaling';
import { Widget } from '@lumino/widgets';

export interface IFiltersType {
output: boolean;
}

export interface IDisplayState {
/**
* The index of the currently selected match
Expand Down Expand Up @@ -64,6 +68,16 @@ export interface IDisplayState {
* Whether or not the replace entry row is visible
*/
replaceEntryShown: boolean;

/**
* What should we include when we search?
*/
filters: IFiltersType;

/**
* Is the filters view open?
*/
filtersOpen: boolean;
}

export interface ISearchMatch {
Expand Down Expand Up @@ -123,10 +137,15 @@ export interface ISearchProvider<T extends Widget = Widget> {
*
* @param query A RegExp to be use to perform the search
* @param searchTarget The widget to be searched
* @param filters Filter parameters to pass to provider
*
* @returns A promise that resolves with a list of all matches
*/
startQuery(query: RegExp, searchTarget: T): Promise<ISearchMatch[]>;
startQuery(
query: RegExp,
searchTarget: T,
filters: IFiltersType
): Promise<ISearchMatch[]>;

/**
* Clears state of a search provider to prepare for startQuery to be called
Expand Down Expand Up @@ -194,4 +213,10 @@ export interface ISearchProvider<T extends Widget = Widget> {
* the replace option.
*/
readonly isReadOnly: boolean;

/**
* Set to true if the widget under search has outputs to search.
* Defaults to false.
*/
readonly hasOutputs?: boolean;
}
Expand Up @@ -69,12 +69,14 @@ export class CodeMirrorSearchProvider
*
* @param query A RegExp to be use to perform the search
* @param searchTarget The widget to be searched
* @param [filters={}] Filter parameters to pass to provider
*
* @returns A promise that resolves with a list of all matches
*/
async startQuery(
query: RegExp,
searchTarget: Widget
searchTarget: Widget,
filters = {}
): Promise<ISearchMatch[]> {
if (!CodeMirrorSearchProvider.canSearchOn(searchTarget)) {
throw new Error('Cannot find Codemirror instance to search');
Expand Down Expand Up @@ -298,6 +300,9 @@ export class CodeMirrorSearchProvider
return undefined;
}

get editor(): CodeMirrorEditor {
return this._cm;
}
/**
* Set whether or not the CodemirrorSearchProvider will wrap to the beginning
* or end of the document on invocations of highlightNext or highlightPrevious, respectively
Expand Down

0 comments on commit 37c7a64

Please sign in to comment.