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

Update CodeMirror and lezer packages #15987

Merged
merged 10 commits into from
Mar 16, 2024

Conversation

krassowski
Copy link
Member

@krassowski krassowski commented Mar 13, 2024

References

PSA: if you see ../codemirror/src/extension.ts(823,17): error TS2322: Type error after merging this PR, you need to call jlpm clean before rebuilding again to remove old versions from packages dist.

    ✖  @jupyterlab/lsp-extension:build:all
       > @jupyterlab/lsp-extension@4.2.0-alpha.1 build
       > tsc -b
       
       ../codemirror/src/extension.ts(823,17): error TS2322: Type 'import("~/jupyterlab/node_modules/@codemirror/commands/node_modules/@codemirror/view/dist/index").Command' is not assignable to type 'import("~/jupyterlab/node_modules/@codemirror/view/dist/index").Command'.
         Types of parameters 'target' and 'target' are incompatible.
           Type 'import("~/jupyterlab/node_modules/@codemirror/view/dist/index").EditorView' is not assignable to type 'import("~/jupyterlab/node_modules/@codemirror/commands/node_modules/@codemirror/view/dist/index").EditorView'.
             Types have separate declarations of a private property 'dispatchTransactions'.
       ../codemirror/src/extension.ts(828,17): error TS2322: Type 'import("~/jupyterlab/node_modules/@codemirror/commands/node_modules/@codemirror/view/dist/index").Command' is not assignable to type 'import("~/jupyterlab/node_modules/@codemirror/view/dist/index").Command'.
       ../codemirror/src/extension.ts(829,17): error TS2322: Type 'import("~/jupyterlab/node_modules/@codemirror/commands/node_modules/@codemirror/view/dist/index").Command' is not assignable to type 'import("~/jupyterlab/node_modules/@codemirror/view/dist/index").Command'.
       ../codemirror/src/extension.ts(835,17): error TS2322: Type 'import("~/jupyterlab/node_modules/@codemirror/commands/node_modules/@codemirror/view/dist/index").Command' is not assignable to type 'import("~/jupyterlab/node_modules/@codemirror/view/dist/index").Command'.
       ../codemirror/src/extension.ts(836,17): error TS2322: Type 'import("~/jupyterlab/node_modules/@codemirror/commands/node_modules/@codemirror/view/dist/index").Command' is not assignable to type 'import("~/jupyterlab/node_modules/@codemirror/view/dist/index").Command'.
       ../codemirror/src/extension.ts(842,17): error TS2322: Type 'import("~/jupyterlab/node_modules/@codemirror/commands/node_modules/@codemirror/view/dist/index").Command' is not assignable to type 'import("~/jupyterlab/node_modules/@codemirror/view/dist/index").Command'.
       npm ERR! Lifecycle script `build` failed with error: 
       npm ERR! Error: command failed 
       npm ERR!   in workspace: @jupyterlab/lsp-extension@4.2.0-alpha.1 
       npm ERR!   at location: ~/jupyterlab/packages/lsp-extension 

Code changes

CodeMirror core:

  • @codemirror/state 6.2.0 → 6.4.1
  • @codemirror/view 6.9.6 → 6.26.0
  • @codemirror/search 6.3.0 → 6.5.6
  • @codemirror/language 6.6.0 → 6.10.1
  • @codemirror/autocomplete 6.5.1 → 6.15.0
  • @codemirror/commands 6.2.3 → 6.3.3

Language modes

  • @codemirror/lang-css: 6.1.1 → 6.2.1
  • @codemirror/lang-html: 6.4.3 → 6.4.8
  • @codemirror/lang-javascript: 6.1.7 → 6.2.2
  • @codemirror/lang-markdown: 6.1.1 → 6.2.4
  • @codemirror/lang-python: 6.1.3 → 6.1.4
  • @codemirror/lang-sql: 6.4.1 → 6.6.1
  • @codemirror/lang-wast: 6.0.1 → 6.0.2
  • @codemirror/lang-xml: 6.0.2 → 6.1.0
  • @codemirror/legacy-modes 6.3.2 → 6.3.3

Lezer

  • @lezer/common: 1.0.2 → 1.2.1,
  • @lezer/generator: 1.2.2 → 1.7.0,
  • @lezer/highlight: 1.1.4 → 1.2.0,
  • @lezer/markdown: 1.0.2 → 1.2.0,

User-facing changes

Hundreds of bug fixes in editor functionality, including a number of compatibility fixes. Some highlights:

  • @codemirror/view:
    • numerous fixes for compatibility with mobile devices (iOS, Mobile Safari and Android GBoard)
  • @codemirror/search:
  • @codemirror/language:
    • Fix an issue where, when a lot of code is visible in the initial editor, the bottom bit of code is shown without highlighting for one frame.

    • Indentation now works a lot better in mixed-language documents that interleave the languages in a complex way.

    • Code folding is now able to pick the right foldable syntax node when the line end falls in a mixed-parsing language that doesn't match the target node.

  • @codemirror/commands:
    • Make Cmd-Backspace and Cmd-Delete on macOS delete to the next line wrap point, not the start/end of the line.

    • Make insertNewlineAndIndent properly count indentation for tabs when copying over the previous line's indentation.

    • Fix a bug in insertNewlineAndIndent that would delete text between brackets if it had no corresponding AST node.

  • @codemirror/lang-css:
    • Allow keyframe blocks to be code-folded.

  • @codemirror/lang-html:
    • Parse script tags with application/json type as JSON syntax.

    • Add highlighting for the content of <script> tags with a type of importmap or speculationrules.

  • @codemirror/lang-markdown:
    • Support code folding for GFM tables.

  • @codemirror/lang-sql:
    • Don't tokenize identifiers after periods as anything but plain identifiers.

    • Remove use of negative lookbehind in a regular expression, which recent versions of Safari still don't support.

    • The PL/SQL dialect now correctly handles q'[]'-quoting syntax.

  • @codemirror/lang-xml:
    • Add an autoCloseTags extension that closes tags on typing > or /. Enable it by default in the xml() language support.

  • @codemirror/legacy-modes:
    • In Shell mode, don't allow spaces in heredoc tokens.

Backwards-incompatible changes

None

Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

as that version requires that `allowMultipleSelections` extension
is enabled to set multiple cursors; it is enabled by default in
JupyterLab but was previously filtered out in tests setup.
This commit adds it to the include list of extensions to use in tests.
The cast from CodeMirror's `Rect` to `ICoordinate` was incorrect and was
masking the fact that the former did not have `x`, `y`, `width`, `height`,
nor `toJSON()`, along with the fact that CodeMirror could also return
`null`. This lead to type safety violations and bad failure in a test.
@krassowski krassowski marked this pull request as ready for review March 14, 2024 11:59
@krassowski
Copy link
Member Author

krassowski commented Mar 14, 2024

It appears that search in selection test failures are relevant as these failed in all attempts:

    [jupyterlab] › test/jupyterlab/notebook-search.test.ts:349:7 › Notebook Search › Search in selected text 
    [jupyterlab] › test/jupyterlab/texteditor.test.ts:45:7 › Text Editor Tests › Selection in highlighted line 

This appears to be a CSS issue:

Actual Expected
image image

@krassowski krassowski marked this pull request as draft March 14, 2024 15:24
@github-actions github-actions bot added tag:CSS For general CSS related issues and pecadilloes Design System CSS labels Mar 15, 2024
@krassowski krassowski marked this pull request as ready for review March 15, 2024 12:32
- The ``CodeEditor.ICoordinate`` interface was corrected to not include ``toJSON()``, ``x``, ``y``,
``width`` and ``height``; these properties were never set by methods returning ``ICoordinate``
and they were never used by methods accepting it.
- ``CodeEditor.getCoordinateForPosition`` return type was corrected to clarify that it can return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be considered as a breaking change? Thinking this may affect some extensions not checking for the value to be null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I guess this change is ok, since it's a "fix" of the API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a bug fix - if an extension was not checking for a non-null value (which it most likely did not) its users would have a runtime error in some cases which is arguably worse than the developer having a build time error after upgrading packages.

Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@krassowski
Copy link
Member Author

It looks like [jupyterlab] › test/jupyterlab/texteditor.test.ts:45:7 › Text Editor Tests › Selection in highlighted line still needs work.

@krassowski krassowski marked this pull request as draft March 15, 2024 15:27
@krassowski krassowski marked this pull request as ready for review March 15, 2024 16:34
@krassowski krassowski merged commit 9eea31b into jupyterlab:main Mar 16, 2024
80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment