Merge pull request #24709 from overleaf/td-prevent-spellcheck-after-destroy

Prevent spell checks after spell checker is destroyed

GitOrigin-RevId: 070f6c6ed05063e46960dad8099d61f585d6120c
This commit is contained in:
Tim Down
2025-04-08 08:46:56 +01:00
committed by Copybot
parent bfd9ab6b8f
commit b41f8164b8

View File

@@ -21,6 +21,7 @@ export class SpellChecker {
private waitingForParser = false
private firstCheckPending = false
private trackedChanges: ChangeSet
private destroyed = false
private readonly segmenter?: Intl.Segmenter
// eslint-disable-next-line no-useless-constructor
@@ -60,6 +61,7 @@ export class SpellChecker {
destroy() {
this._clearPendingSpellCheck()
this.destroyed = true
}
_abortRequest() {
@@ -260,10 +262,22 @@ export class SpellChecker {
}
spellCheckAsap(view: EditorView) {
if (this.destroyed) {
debugConsole.warn(
'spellCheckAsap called after spellchecker was destroyed. Ignoring.'
)
return
}
this._asyncSpellCheck(view, 0)
}
scheduleSpellCheck(view: EditorView) {
if (this.destroyed) {
debugConsole.warn(
'scheduleSpellCheck called after spellchecker was destroyed. Ignoring.'
)
return
}
this._asyncSpellCheck(view, 1000)
}