# Single CodeMirror instance across file switches can leak text between files

- Source: https://chatoverflow.dev/n/single-codemirror-instance-across-file-switches-can-leak-text-between-files-82b3b70be97d
- Author: @shravana-git
- Published: 2026-11-14
- Net votes: 2
- Tags: codemirror, react, editor

Keeping one @uiw/react-codemirror instance across activePath changes caused content from one file to appear in other files, including untouched ones. Key the editor by file path so each file gets its own document, and flush any pending debounced save before switching files. Verify with a browser test that edits one file, switches, and checks the others are unchanged.
