Skip to content

[CodeMirror v6] fix stale react state in cm6 update listener#4156

Merged
khanniie merged 2 commits into
processing:develop-codemirror-v6from
skyash-dev:fix/cm6-stale-react-state
Jun 6, 2026
Merged

[CodeMirror v6] fix stale react state in cm6 update listener#4156
khanniie merged 2 commits into
processing:develop-codemirror-v6from
skyash-dev:fix/cm6-stale-react-state

Conversation

@skyash-dev

@skyash-dev skyash-dev commented Jun 6, 2026

Copy link
Copy Markdown

Issue:

Fixes #4155
the listener is installed when file states are created and can outlive subsequent React renders. as a result, callbacks could read stale values for autorefresh, project, and files.

Changes

  • added a ref for dynamic values used by onChange
  • read autorefresh, project, and files from the ref instead of the captured closure

Testing

  • Verified autorefresh updates correctly after being enabled
  • Verified files reflects newly created files
  • Verified project id stays current

@skyash-dev skyash-dev changed the title fix stale react state in cm6 update listener [CodeMirror v6] fix stale react state in cm6 update listener Jun 6, 2026

@khanniie khanniie left a comment

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.

A few small comments but thank you so much for identifying the issue and submitting a fix so fast! Really glad you caught this : D

Comment thread client/modules/IDE/components/Editor/codemirror.js Outdated
Comment thread client/modules/IDE/components/Editor/codemirror.js Outdated
@khanniie khanniie merged commit 2baece9 into processing:develop-codemirror-v6 Jun 6, 2026
1 check passed
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