Skip to content

Fix code-block rendering, save integrity, and highlight restoration - #9

Merged
BinaryOutlook merged 11 commits into
mainfrom
fixes/codeblock-v0.2.1
Sep 17, 2026
Merged

BinaryOutlook merged 11 commits into
mainfrom
fixes/codeblock-v0.2.1

Conversation

@BinaryOutlook

@BinaryOutlook BinaryOutlook commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Code blocks could lose recent edits during source switching, turn into toolbar text when quoted content was saved, or render as prose when their fences were indented. This change preserves code through those paths and restores highlighting when another block becomes active.

Issue Change
#2 Capture current edits before switching modes and invalidate stale synchronization callbacks.
#3 Reuse block serialization inside quotes, retaining code whitespace and excluding controls/rendered diagrams.
#1 Recognize fences with zero to three leading spaces and remove only the opening indentation from content.
#7 Restore inactive regular blocks through the existing display-mode transition.
#4 Use the existing code foreground token in quoted blocks, preserving syntax-token colors.

Each fix has a separate commit and regression coverage. Production changes are confined to src/webview/editor.js and one CSS declaration. The fence change follows the CommonMark indentation rules; this is not a claim of full CommonMark compatibility.

Validation:

  • Local npm test: 782 browser tests passed, including 44 new regression cases. Local unit suites had no failures; 11 converter-dependent checks were skipped locally.
  • The installed development VSIX passed the real source-mode keyboard shortcut immediately after typing, native save/reopen, fence rendering, inactive highlighting, and quoted-code color checks. The native scenario is included in every installed-VSIX CI lane.
  • After rebasing: compilation, lint, all unit files (219 passed, 11 converter-dependent skips), and documentation checks passed.
  • The branch includes the latest main (4d16748), whose validation passed, including the merged Windows browser-probe fixes.
  • The first PR run passed Ubuntu/macOS but exposed Windows clipboard CRLF expectations in the new tests and the pre-existing native-save overlap reported in Native Save can write stale content when queued host edits overlap save preparation #11. The clipboard assertions now normalize only CRLF to LF; spaces, tabs, trailing blank lines, saved Markdown, and exported output retain their existing checks. The native suite waits for the source round trip to reach the host before beginning the separate quoted-code save scenario; it still invokes Save immediately after that scenario's new edit.
  • Follow-up local validation: all 27 affected browser tests passed, and the actual revised native suite passed against the CI candidate VSIX on VS Code 1.85.0.
  • Final hosted validation: all six gates passed in run 35097525193 for branch head bd33079cbff656cdef44e354ad5c0ea83eb16883. Ubuntu, macOS, and Windows each passed all 782 browser tests with retries disabled. All four lanes, including VS Code 1.85.0, passed 237 unit/converter checks without skips and the installed-VSIX native flows, including all six code-block assertions.
  • The tested clean candidate is stamped with GitHub's PR test-merge commit 64f726b203bf9620c1dc56a4edc1227f6bcdd101 (parents: current main and the branch head above). Its SHA-256 is 209265bb72a8f6d19abeedb989d67f6e992e6ada908c895149431ba4eee79a67; the packaged editor JavaScript and CSS match the reviewed source byte for byte. This is a CI test merge, not a merge into main.
  • Public diff/documentation checks use synthetic examples. Commit identity is project-level, commit timestamps use UTC, and local paths, private document contents, screenshots, and raw local logs are excluded.

Issue #5 remains open: list continuation needs coordinated parser and serializer changes. The follow-up investigation records the remaining boundary, including wider numbered-list markers. Active code editing retains the existing plain-text behavior; #7 restores highlighting after leaving a block. General blockquote prose colors are outside #4's code-specific change.

Issue #11 also remains open. Native Save can omit a newer snapshot when an earlier queued host mutation overlaps save preparation. This was reproduced twice on the unmodified main VSIX using plain text, with an acknowledged-earlier-edit control passing. It requires a separate provider/save-queue change; this PR does not claim to fix that race.

Closes #1.
Closes #2.
Closes #3.
Closes #4.
Closes #7.

Binary Markdown Contributors added 7 commits September 16, 2026 12:15
Capture the current mode before switching and invalidate stale callbacks. Regressions cover host commands, pending idle work, undo, and equation editing. Fixes #2.
Reuse the block serializer and retain code whitespace while excluding editor controls and rendered diagrams. Fixes #3.
Track up to three opening spaces and dedent content by that amount. Preserve tabs, deeper indentation, fence rules, and special blocks. Fixes #1.
Restore inactive regular blocks through the existing display transition because nested editable blocks share focus. Preserve active plain-text editing. Fixes #7.
Use the existing code text token without overriding syntax token colors or broadening the change to quote prose. Fixes #4.
Exercise the real source-mode keybinding, native save and reopen, fence rendering, focus restoration, and quoted-code colors in every native CI lane.
Document synthetic follow-up cases for #5 and the parser/serializer work requiring a separate reviewed change.
@BinaryOutlook
BinaryOutlook merged commit 4784d25 into main Sep 17, 2026
7 checks passed
BinaryOutlook added a commit that referenced this pull request Sep 17, 2026
#14)

Integrate PRs #8, #9, #10, and #12, preserving their commits and resolved conflicts. The combined revision passed all six VSIX validation jobs in run 35242617333. Closes #1, closes #2, closes #3, closes #4, closes #7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment