Skip to content

Commit

Permalink
fix: #331 changing contents during the onChange callback throws a s…
Browse files Browse the repository at this point in the history
…election error
  • Loading branch information
josdejong committed Nov 8, 2023
1 parent b07d08d commit 6e511fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/components/modes/textmode/TextMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,13 @@
updateCanUndoRedo()
emitOnChange(content, previousContent)
emitOnSelect()
// We emit OnSelect on the next tick to cater for the case where
// the user changes the content directly inside the OnChange callback.
// This change will be dispatched by Svelte on the next tick. Before
// that tick, emitOnSelect would be fired based on the "old" contents,
// which may be out of range when the replacement by the user is shorter.
tick().then(emitOnSelect)
}
function updateLinter(validator: Validator | null) {
Expand Down

0 comments on commit 6e511fa

Please sign in to comment.