Skip to content
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

Port to JupyterLab 4.0/CodeMirror6 #128

Merged
merged 13 commits into from
Jul 4, 2023

Conversation

krassowski
Copy link
Collaborator

@krassowski krassowski commented Jul 3, 2023

Closes #127:

  • supports JupyterLab 4.0
  • renames npm package to @jupyterlab-contrib/spellchecker for consistency

A big step towards #39:

  • makes it possible to check spelling in comments (enabled by default) and strings (disabled by default)
  • enables spellcheck for Python and R (can be disabled in settings by removing mime-type for text/x-ipython and text/x-rsrc correspondingly, or by disabling "check spelling in comments").

Previous implementation used a custom mode overlaid on top of the active highlighting mode, which repeatedly executed regular expressions on the incoming stream. This meant no awareness of syntax which required masking out undesired tokens post-hoc by combining CSS selectors of tokens and prevented checking only selected fragments of code, e.g. comments and strings.

This PR uses alternative approach of masking out syntax tokens with whitespaces and splitting into words with a single ES2020 re.matchAll call, followed by decorating the syntax errors using the linter plugin (which is super fast and also enables us to easily display gutter and a panel of errors - if we want to add it later).

Parsing and checking 150 paragraphs, 13 227 words (lorem ipsum) takes 21 milliseconds on Chromium. It is difficult to measure equivalent performance with the old version, but it seems broadly comparable, with much potential to improve if we move spellchecking to a webworker in the future.

New class name is used for tokens: cm-lintRange-spell.

Screenshot from 2023-07-04 23-56-13

@github-actions
Copy link

github-actions bot commented Jul 3, 2023

Binder 👈 Launch a binder notebook on branch krassowski/jupyterlab_spellchecker/lab-4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Jupyterlab 4
1 participant