Skip to content

Update CodeMirror to v6 #95

Open
Open

Description

@weirdan

The upgrade guide is available here: https://codemirror.net/docs/migration/

To sum up, everything has changed, so we may just as well use something else.

The rationale for upgrading is mostly small syntax highlighting annoyances.

Activity

  1. alies-dev commented on Nov 8, 2026

    @alies-dev
    Contributor

    Notes on the current editor setup, from working on #143.

    What assets/js/codemirror.js is today

    It contains no psalm.dev code (that all lives in includes/script.php), but it can't be regenerated from anything:

    • Core is labelled 5.52.0 but is not the published 5.52.0 lib/codemirror.js: ~490 lines differ, mostly bundler renames (map$$1), so it looks like a different build of a similar version.
    • addon/lint matches 5.52.0 exactly; mode/clike differs from 5.52.0 by ~90 lines (older copy).
    • mode/php has one local edit (0ccbaed: enum, readonly, match keywords), which upstream 5.65 already has verbatim.
    • Redesign the playground and homepage #143 appends closebrackets, matchbrackets and runmode from 5.65.21.
    • package.json has codemirror: ^5.52.0 (installs 5.65.21) but nothing uses it; build:js only minifies the committed file.

    Cheap step before (or instead of) v6

    Build codemirror.min.js straight from node_modules/codemirror (core, php/clike/xml/javascript/css/htmlmixed modes, lint/closebrackets/matchbrackets/runmode addons), pin the exact version and delete the hand-made codemirror.js. That moves us to the latest 5.x (5.65) and makes later upgrades a version bump. Some of the highlighting annoyances may already be fixed in 5.65's PHP mode.

    What a v6 migration would have to port

    The playground uses the v5 API fairly widely: fromTextArea, the lint addon (getAnnotations/performLint, and its CodeMirror-lint-mark-* classes, also reused in the homepage heading), markText for hover and navigation highlights, addWidget for signature help, runMode for the fix-preview diff highlighting, plus posFromIndex/indexFromPos, coordsChar/charCoords, extraKeys and autoCloseBrackets. v6 has equivalents for all of these (@codemirror/lint, decorations, tooltips, @codemirror/lang-php, closeBrackets), but it is a rewrite of that integration plus a real JS build step (ES modules), not a drop-in update.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions