Skip to content

Commit

Permalink
Uses the browser window's selection as the default search query (#15834)
Browse files Browse the repository at this point in the history
* Revert "Alternate description for disabled filters"

This reverts commit 059fb7e.

* Revert "Revert "Alternate description for disabled filters""

This reverts commit 27ed1d0.

* Uses the browser window's selection as the default search query
  • Loading branch information
JasonWeill committed Mar 14, 2024
1 parent 412cb0a commit ae50922
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions packages/notebook/src/searchprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
ICellModel,
MarkdownCell
} from '@jupyterlab/cells';
import {
CodeMirrorEditor,
IHighlightAdjacentMatchOptions
} from '@jupyterlab/codemirror';
import { IHighlightAdjacentMatchOptions } from '@jupyterlab/codemirror';
import { CodeEditor } from '@jupyterlab/codeeditor';
import { IChangedArgs } from '@jupyterlab/coreutils';
import {
Expand Down Expand Up @@ -289,16 +286,8 @@ export class NotebookSearchProvider extends SearchProvider<NotebookPanel> {
* @returns Initial value used to populate the search box.
*/
getInitialQuery(): string {
const activeCell = this.widget.content.activeCell;
const editor = activeCell?.editor as CodeMirrorEditor | undefined;
if (!editor) {
return '';
}
const selection = editor.state.sliceDoc(
editor.state.selection.main.from,
editor.state.selection.main.to
);
return selection;
// Get whatever is selected in the browser window.
return window.getSelection()?.toString() || '';
}

/**
Expand Down

0 comments on commit ae50922

Please sign in to comment.