From 79e3de74448e44541983e85888fdacb80aef4a89 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Wed, 15 Oct 2025 12:33:49 +0700 Subject: [PATCH] fix: properly unobserve ydoc in inline comments Signed-off-by: Alexander Onnikov --- .../src/components/extension/inlineComment.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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()