diff --git a/plugins/text-editor-resources/src/components/extension/inlineComment.ts b/plugins/text-editor-resources/src/components/extension/inlineComment.ts index 122243addff..ca312793a5c 100644 --- a/plugins/text-editor-resources/src/components/extension/inlineComment.ts +++ b/plugins/text-editor-resources/src/components/extension/inlineComment.ts @@ -251,16 +251,17 @@ function initCommentDecoratorView (options: InlineCommentExtensionOptions, view: if (options.whenSync !== undefined) { await options.whenSync } + commentMap.observe(commentMapObserver) + destructors.push(() => { + commentMap.unobserve(commentMapObserver) + }) + commentMapObserver() } void initObserver() - destructors.push(() => { - commentMap.unobserve(commentMapObserver) - }) - return { destroy () { for (const fn of destructors) fn()