-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notebook search based on data model #11689
Notebook search based on data model #11689
Conversation
Thanks for making a pull request to jupyterlab! |
27964e8
to
1ab2b5e
Compare
904a0b9
to
e535731
Compare
Performance of this PR has been tested manually on the large notebook not_so_obvious_python_stuff.ipynb mentioned in #6756 In the issue, it was mentioned that the gain for the tested notebook is (presumably gain obtained by the associated PR #6824):
In the screencast above we can see that the search for |
Awesome @fcollonval Will a mimetype renderer be obliged to support this new search capability? In other words, what are the impacts for existing renderers such as e.g. https://github.com/jupyterlab/jupyter-renderers? |
No, the additional API has two folds:
/**
* Render a mime model.
*
* @param model - The mime model to render.
* @param highlights - The highlights to render.
*
* @returns A promise which resolves when rendering is complete.
*
* #### Notes
* This method may be called multiple times during the lifetime
* of the widget to update it if and when new data is available.
*/
renderModel(model: IMimeModel, highlights?: IHighlight[]): Promise<void>;
/**
* Highlights text fragment on the widget.
*
* @param highlights - The highlights to render.
*
* @returns A promise which resolves when rendering is complete.
*
* #### Notes
* The highlights are sorted from the lowest to the highest position.
*
* This method may be called multiple times during the lifetime
* of the widget to update it if and when new data is available.
*/
renderHighlights?(highlights: IHighlight[]): Promise<void>;
/**
* A plugin providing search engine for cell outputs.
*/
const search: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab/rendermime-extension:search',
requires: [ISearchProviderRegistry],
activate: (app: JupyterFrontEnd, searchRegistry: ISearchProviderRegistry) => {
textRendererFactory.mimeTypes.forEach(mimeType => {
searchRegistry.registerMimeTypeSearchEngine(mimeType, TextSearchEngine);
});
[
...markdownRendererFactory.mimeTypes,
'text/x-ipythongfm',
'text/x-markdown',
'text/x-gfm'
].forEach(mimeType => {
searchRegistry.registerMimeTypeSearchEngine(
mimeType,
MarkdownSearchEngine
);
});
htmlRendererFactory.mimeTypes.forEach(mimeType => {
searchRegistry.registerMimeTypeSearchEngine(
mimeType,
HTMLStringSearchEngine
);
});
},
autoStart: true
}; Test using |
d3648a8
to
4e4a874
Compare
Comments from the performance meeting:
Edit for VSCode 1.64 update: it is now possible to search for in rendered markdown cells and cell outputs (see announcement). For markdown cell, this duplicate the search in the rendered version (for example if the search matches in both the source and the rendered version, the counter hit will be 2 not one). The feature is optional (new filters available) and turn off by default. The code is there. It search on the model. Then if filter requires it, it will render the outputs. And finally it will search on the rendered markup and outputs (if requested). |
1889e59
to
b25e822
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @afshin
packages/outputarea/src/model.ts
Outdated
*/ | ||
readonly stateChanged: ISignal<IOutputAreaModel, void>; | ||
readonly stateChanged: ISignal<IOutputAreaModel, number | void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this is not needed anymore as the implementation provides a number in all cases. So I removed it.
}); | ||
} | ||
|
||
this.searchProvider.stateChanged.disconnect(this.refresh, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will actually be called in super.dispose()
.
} | ||
super.dispose(); | ||
|
||
this.widget.content.placeholderCellRendered.disconnect( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signal.clearData(this);
is call is the base class (similarly to Widget
)
}); | ||
} | ||
|
||
this.searchProvider.stateChanged.disconnect(this.refresh, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signal.clearData(this);
is called by the base class VDomModel.dispose
. So I'm only reflecting the disconnection as I like the practice to explicit set up and clean up of signal as we do for event listener.
please update galata snapshots |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @fcollonval! This is awesome 🚀
Benchmark reportThe execution time (in milliseconds) are grouped by test file, test type and browser. The mean relative comparison is computed with 95% confidence. Results table
Changes are computed with expected as reference. |
.jp-mimeType-highlight { | ||
background-color: var( | ||
--jp-search-unselected-match-background-color | ||
) !important; | ||
color: var(--jp-search-unselected-match-color) !important; | ||
} | ||
|
||
.jp-mod-selected.jp-mimeType-highlight { | ||
background-color: var(--jp-search-selected-match-background-color) !important; | ||
color: var(--jp-search-selected-match-color) !important; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fcollonval it seems to me that .jp-mimeType-highlight
is not used, is this correct or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct - this is an artifact of my trial for searching the unrendered output.
- `.jp-mimeType-highlight`: jupyterlab#11689 (comment) - `.jp-Notebook-render *`: jupyterlab#9382 (comment)
…13255) * Remove unused styles: - `.jp-DirListing-deadSpace` unused since 10537f4 - `.jp-openJSONSettingsEditor` unused since 94cc691 - `.jp-OutputArea-stdin` unused since c7b8f41 - `.jp-PluginList .jp-SettingsHeader` unused since 6dc35da - `.jp-PluginList-Searcher` unused since 3f65d55 - `.jp-RedirectForm` unused since 555d84b * Fix abandoned style and lettercase typo in `jp-PluginList-entry-label` Abandoned since 6b37ab4 * Remove unused `.lm-TabBar-WindowTabLabel` rule. I could not find when it was removed from phosphor, but it was introduced into JupyterLab in 2016 in: 652b8b5 * Remove unused style rules with no usage trace in git history - `.jp-mimeType-highlight`: #11689 (comment) - `.jp-Notebook-render *`: #9382 (comment)
…upyterlab#13255) * Remove unused styles: - `.jp-DirListing-deadSpace` unused since 10537f4 - `.jp-openJSONSettingsEditor` unused since jupyterlab@94cc691 - `.jp-OutputArea-stdin` unused since c7b8f41 - `.jp-PluginList .jp-SettingsHeader` unused since jupyterlab@6dc35da - `.jp-PluginList-Searcher` unused since jupyterlab@3f65d55 - `.jp-RedirectForm` unused since jupyterlab@555d84b * Fix abandoned style and lettercase typo in `jp-PluginList-entry-label` Abandoned since jupyterlab@6b37ab4 * Remove unused `.lm-TabBar-WindowTabLabel` rule. I could not find when it was removed from phosphor, but it was introduced into JupyterLab in 2016 in: 652b8b5 * Remove unused style rules with no usage trace in git history - `.jp-mimeType-highlight`: jupyterlab#11689 (comment) - `.jp-Notebook-render *`: jupyterlab#9382 (comment)
…upyterlab#13255) * Remove unused styles: - `.jp-DirListing-deadSpace` unused since 10537f4 - `.jp-openJSONSettingsEditor` unused since jupyterlab@94cc691 - `.jp-OutputArea-stdin` unused since c7b8f41 - `.jp-PluginList .jp-SettingsHeader` unused since jupyterlab@6dc35da - `.jp-PluginList-Searcher` unused since jupyterlab@3f65d55 - `.jp-RedirectForm` unused since jupyterlab@555d84b * Fix abandoned style and lettercase typo in `jp-PluginList-entry-label` Abandoned since jupyterlab@6b37ab4 * Remove unused `.lm-TabBar-WindowTabLabel` rule. I could not find when it was removed from phosphor, but it was introduced into JupyterLab in 2016 in: 652b8b5 * Remove unused style rules with no usage trace in git history - `.jp-mimeType-highlight`: jupyterlab#11689 (comment) - `.jp-Notebook-render *`: jupyterlab#9382 (comment) (cherry picked from commit 1777055)
…con alignment in plugin list Remove some unused CSS styles and fix icon alignment in plugin list (jupyterlab#13255) * Remove unused styles: - `.jp-DirListing-deadSpace` unused since 10537f4 - `.jp-openJSONSettingsEditor` unused since jupyterlab@94cc691 - `.jp-OutputArea-stdin` unused since c7b8f41 - `.jp-PluginList .jp-SettingsHeader` unused since jupyterlab@6dc35da - `.jp-PluginList-Searcher` unused since jupyterlab@3f65d55 - `.jp-RedirectForm` unused since jupyterlab@555d84b * Fix abandoned style and lettercase typo in `jp-PluginList-entry-label` Abandoned since jupyterlab@6b37ab4 * Remove unused `.lm-TabBar-WindowTabLabel` rule. I could not find when it was removed from phosphor, but it was introduced into JupyterLab in 2016 in: 652b8b5 * Remove unused style rules with no usage trace in git history - `.jp-mimeType-highlight`: jupyterlab#11689 (comment) - `.jp-Notebook-render *`: jupyterlab#9382 (comment) (cherry picked from commit 1777055)
…ent in plugin list (#13280) Remove some unused CSS styles and fix icon alignment in plugin list (#13255) * Remove unused styles: - `.jp-DirListing-deadSpace` unused since 10537f4 - `.jp-openJSONSettingsEditor` unused since 94cc691 - `.jp-OutputArea-stdin` unused since c7b8f41 - `.jp-PluginList .jp-SettingsHeader` unused since 6dc35da - `.jp-PluginList-Searcher` unused since 3f65d55 - `.jp-RedirectForm` unused since 555d84b * Fix abandoned style and lettercase typo in `jp-PluginList-entry-label` Abandoned since 6b37ab4 * Remove unused `.lm-TabBar-WindowTabLabel` rule. I could not find when it was removed from phosphor, but it was introduced into JupyterLab in 2016 in: 652b8b5 * Remove unused style rules with no usage trace in git history - `.jp-mimeType-highlight`: #11689 (comment) - `.jp-Notebook-render *`: #9382 (comment) (cherry picked from commit 1777055)
References
This is a preliminary work for #11574 that switches the search feature in the notebook from view (aka CodeMirror and DOM nodes) search to data model (aka modelDB) for the inputs. The search on outputs is disabled by default and will looked at the rendered DOM tree if activated (when using virtual rendering this will trigger a warning that it may takes some time as outputs rendering will be needed).
Code changes
@jupyterlab/documentsearch
:On Markdown cells, they are unrendered when the user is highlighting next or previous match that are in a markdown cell.
OutputArea
widget (and correct some bugs) as if trimmed the output area will only show the first outputs (following Only show the head of the outputs and ensure iopub outputs are correctly displayed #11457)User-facing changes
Backwards-incompatible changes
ISearchProvider
API is modified.