Skip to content

Commit

Permalink
fix: #381 method set() sometimes throwing an error in text mode
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Jan 19, 2024
1 parent 0d49b66 commit 2dc62f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/lib/components/JSONEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@
// new editor id -> will re-create the editor
instanceId = uniqueId()
await tick() // await re-render (creating the new editor)
// update content *after* re-render, so that the new editor will trigger an onChange event
content = newContent
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/modes/textmode/TextMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,16 @@
const newText = getText(newContent, indentation, parser)
const isChanged = !isEqual(newContent, content)
const previousContent = content
content = newContent
text = newText
debug('setCodeMirrorContent', { isChanged, forceUpdate })
if (!codeMirrorView || (!isChanged && !forceUpdate)) {
return
}
content = newContent
text = newText
if (!disableTextEditor(text, acceptTooLarge)) {
// keep state
// to reset state: codeMirrorView.setState(EditorState.create({doc: text, extensions: ...}))
Expand Down

0 comments on commit 2dc62f0

Please sign in to comment.