Skip to content

fix: restore CM6 editor visual consistency#4144#4147

Merged
khanniie merged 2 commits into
processing:develop-codemirror-v6from
parthjadhao01:fix/cm6-editor-visual-consistency
Jun 3, 2026
Merged

fix: restore CM6 editor visual consistency#4144#4147
khanniie merged 2 commits into
processing:develop-codemirror-v6from
parthjadhao01:fix/cm6-editor-visual-consistency

Conversation

@parthjadhao01
Copy link
Copy Markdown
Contributor

@parthjadhao01 parthjadhao01 commented Jun 3, 2026

Issue:

Fixes #4144

The CM6 branch had three visual inconsistencies compared to the current CM5 editor: temporary layout compression during font-size changes, missing fold gutter styling, and the fold collapsed placeholder not matching CM5's appearance.

Demo:

Befor :

Screen.Recording.2026-06-03.at.5.24.43.PM.mov

After :

Screen.Recording.2026-06-03.at.5.27.13.PM.mov

Changes:

  • stateUtils.js — Added fontSizeCpt Compartment using EditorView.theme() so font-size changes go through CM6's state system instead of direct DOM manipulation, preventing layout compression. Added createFoldMarker using the official foldGutter({ markerDOM }) API to render fold arrows using the same SVG icons as CM5 (codefold-icon-open / codefold-icon-closed). Used window.document explicitly to avoid shadowing by the document parameter in createNewFileState.
  • codemirror.js — Wired fontSizeCpt reconfigure on font-size preference change, following the same Compartment pattern as lineNumbersCpt, lineWrappingCpt etc.
  • _editor.scss — Added fold gutter styles translated from CM5 (.CodeMirror-foldgutter-*.cm-foldGutter, .cm-fold-open, .cm-fold-closed) and fold placeholder styles (.CodeMirror-foldmarker.cm-foldPlaceholder) using the same theme variables.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • has no typecheck errors (npm run typecheck)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #4144
  • meets the standards outlined in the accessibility guidelines

@parthjadhao01 parthjadhao01 changed the title fix: restore CM6 editor visual consistency with CM5 #4144 fix: restore CM6 editor visual consistency#4144 Jun 3, 2026
Copy link
Copy Markdown
Member

@khanniie khanniie left a comment

Choose a reason for hiding this comment

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

Looks super good! Appreciate the fix and fast turnaround!

Comment thread client/styles/components/_editor.scss Outdated

.cm-foldGutter .cm-gutterElement {
cursor: pointer;
// !important needed to override CM6's inline display style on gutter elements
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's avoid using !important if possible. I think if you add enough specificity to the CSS it should be possible override it naturally

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, removed the !important flags

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you so much!

@khanniie khanniie merged commit 2d8e9ba into processing:develop-codemirror-v6 Jun 3, 2026
1 check passed
@parthjadhao01 parthjadhao01 deleted the fix/cm6-editor-visual-consistency branch June 3, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants