Repository navigation
Conversation
…pdates In IR mode, both full-document replacement paths (setValue, used by the extension host after external file changes, and applyAIResult's partial AI replace) only re-ran the Lute DOM rewrite plus the data-render='2' preview pass. Neither mounts CodeMirror on regular code blocks: processCodeRender short-circuits them to ensureSpecialCodeBlockPreview, which only handles math/mermaid/plantuml. After any external update every code block degraded to plain rendered pre/code until the user clicked it once to re-activate the editor. - Call renderCodeBlocks after the rewrite in both IR paths, matching the wysiwyg branch (renderDomByMd) and the edit-mode switch path. Lazy mounting keeps the cost bounded: only blocks near the viewport get a CodeMirror instance, others render as placeholders. - Drop the stock vditor inline max-height cap (window.outerHeight - 40) from codeRender. Inside the webview outerHeight is unreliable (it can be 0) and code-block height is already governed by the --cm-block-max-height setting. The idempotency check now detects the inserted copy button instead of the maxHeight side effect, which also stays correct when DOM is cloned.
This was referenced Sep 16, 2026
ONEGAYI
added a commit
to ONEGAYI/vscode-office
that referenced
this pull request
Sep 16, 2026
Author
|
Closing due to inactivity — no review feedback after ~3 weeks. The commits remain available via |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
1. IR mode: code blocks lose their CodeMirror editors after external content updates
When the document is replaced wholesale in IR mode — i.e. after an external file change (the extension host posts
update, the webview callseditor.setValue()) or an AI selection replace (applyAIResult) — every code block degrades to plain renderedpre > code: no syntax highlighting, no CodeMirror editing. Clicking the block once re-activates it.2. Stock vditor inline max-height cap on rendered code
codeRenderstill setse.style.maxHeight = (window.outerHeight - 40) + "px"on everypre > codeit processes. Inside a webviewwindow.outerHeightis unreliable (it can even be0), and any code block taller than the cap gets a nested in-block scrollbar on top of the document scroll. Code-block height is already governed in this fork by the--cm-block-max-heightsetting (with its expand/collapse affordance), so the inline cap is both buggy and inconsistent with that system.Root cause
For problem 1: both IR full-replace paths only re-run the Lute DOM rewrite plus the
.vditor-ir__preview[data-render='2']→processCodeRenderpass. That pass never mounts CodeMirror on regular code blocks — it short-circuits them toensureSpecialCodeBlockPreview, which only handles math/mermaid/plantuml blocks. The CodeMirror mount entry pointrenderCodeBlocks(vditor)was simply never called on these paths. The wysiwyg branch does not have the bug becauserenderDomByMdcallsrenderCodeBlocksafter the rewrite.For problem 2: stock vditor behavior carried over in
codeRender.ts.Fix
vditor/src/index.ts: callrenderCodeBlocks(vditor)(+setupLazyCodeMirrorObserver) after the DOM rewrite insetValue's IR branch, and make theapplyAIResultrenderCodeBlockscall unconditional instead of wysiwyg-only — matchingrenderDomByMdand the edit-mode switch path. Lazy mounting keeps the cost bounded: only blocks near the viewport get a CodeMirror instance, off-screen blocks render as placeholders and mount on scroll.vditor/src/ts/markdown/codeRender.ts: remove the inline max-height assignment; the idempotency guard now detects the inserted copy button (.vditor-copyprevious sibling) instead of the maxHeight side effect — which also stays correct when the processed DOM is cloned.Verification
Built the vditor subpackage (
npm run build) and drove the built bundle in a real browser against a wysiwyg and an IR editor instance:setValue(external update): before the fixcmHostsis empty and the barepre > codestays plain; clicking the block mounts CodeMirror. After the fix, CodeMirror stays mounted at the initial/immediate/settled checkpoints;getValue()round-trips.setValue).codeRender: called twice on the same block — exactly one copy button inserted, no inline max-height..cm-scroller's computed style, unrelated to this inline style).The AI replace path fix is the same pattern as the verified
setValuepath (that specific panel flow was not driven end-to-end in the browser).