Skip to content

Commit

Permalink
Fix undo/redo history affecting multiple files after switching in cod…
Browse files Browse the repository at this point in the history
…eMirror (#405)

* Fix undo/redo history affecting multiple files after switching in CodeMirror.

* add changeset
  • Loading branch information
swk777 authored Oct 22, 2024
1 parent f41c8ce commit 5fa7e4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/short-tigers-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@srcbook/web': patch
---

Fix undo/redo history affecting multiple files after switching in codeMirror
8 changes: 7 additions & 1 deletion packages/web/src/components/apps/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export function CodeEditor({
const extensions = languageExtension ? [languageExtension] : [];

return (
<CodeMirror value={source} theme={codeTheme} extensions={extensions} onChange={onChange} />
<CodeMirror
key={path}
value={source}
theme={codeTheme}
extensions={extensions}
onChange={onChange}
/>
);
}

Expand Down

0 comments on commit 5fa7e4b

Please sign in to comment.