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