diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c843ab..9dc4815 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Markdown Editor Optimized (MEO) --- ## Unreleased +- Fixed the selection formatting toolbox flickering while highlighting text - Added link-reference definitions as visible linked lists in HTML and PDF exports, and restored copying selections across rendered blocks - Added configurable CodeMirror keymap via `markdownEditorOptimized.keymap` - Hardened external document sync (git/LLM/outside editors): prefer host content on conflict, fix stuck applyingExternal, Reload recovery diff --git a/webview/src/editor.ts b/webview/src/editor.ts index 2b14dcd..054c480 100644 --- a/webview/src/editor.ts +++ b/webview/src/editor.ts @@ -987,11 +987,12 @@ export function createEditor({ return; } + if (selectionPointerId !== null) { + return; + } + const selection = view.state.selection.main; if (selection.empty) { - if (selectionPointerId !== null) { - return; - } onSelectionChange({ visible: false }); return; } @@ -1786,6 +1787,17 @@ export function createEditor({ parent, scrollTo: initialScrollTo }); + + const finishSelectionOutsideEditor = (event: PointerEvent): void => { + if (selectionPointerId !== event.pointerId) { + return; + } + selectionPointerId = null; + scheduleSelectionChangeEmit(); + }; + window.addEventListener('pointerup', finishSelectionOutsideEditor); + window.addEventListener('pointercancel', finishSelectionOutsideEditor); + if (typeof initialTopLine === 'number' && Number.isFinite(initialTopLine)) { restoreTopVisibleLine(initialTopLine, initialTopLineOffset, { syncCursor: true }); } @@ -1940,6 +1952,8 @@ export function createEditor({ view.focus(); }, destroy() { + window.removeEventListener('pointerup', finishSelectionOutsideEditor); + window.removeEventListener('pointercancel', finishSelectionOutsideEditor); gitBlameHover?.destroy(); gitBlameHover = null; gitDiffOverviewRuler?.destroy();