镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(composer): keep ~ in typed inline code spans - #3014

Merged
dr0uleau merged 2 commits into
block:mainfrom
bwester:fizz/fix-code-span-tilde
Nov 9, 2026
Merged

dr0uleau merged 2 commits into
block:mainfrom
bwester:fizz/fix-code-span-tilde

Conversation

@bwester

@bwester bwester commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Typing the closing backtick of an inline code span whose content starts with ~ dropped characters. `~/Foo/bar` became /Foo/ba, `~foo` became fo. The timeline then rendered the stray tildes as GFM strikethrough, which is why affected messages also showed struck-through text.

Cause

spanOf in composer-inline-input.ts measured a span's delimiter with /^[`~]+/ for every span type that isn't strong or emphasis. For an inline code span the raw text begins with the backtick, so a ~ right after it was counted as delimiter. The conversion removed two characters from each end. A ~ can't be a code delimiter, and a backtick can't be a strikethrough delimiter.

Introduced with live Markdown conversion in e89d48c (#455). It first shipped in desktop-v0.7.0-beta.1, so builds from before 2026-10-02 are unaffected.

Change

Count only the backtick run for code spans, and only ~ for strikethrough (new delete case). Production diff: 6 added lines, 1 removed.

Tests

New composer-inline-input.test.ts (28 cases) calls the real applyComposerInlineInput:

  • Basic behavior: bold, italic, strike, code and bold-italic convert with the right marks; surrounding text is kept; double-backtick delimiters and CommonMark's boundary space; typing into the middle of existing text.
  • Stays literal: unclosed spans, empty spans, a selection, a lone ~, and a non-delimiter typed after a span has converted.
  • Regression: every content character survives in code spans containing ~ (`~foo`, `~/A`, `~/Foo/bar`, `~A`, `~`, `~~`, `~~x~~`, in running text, mid-text, double-backtick delimiter).

Fail-then-pass: against unfixed main, 10 of 28 fail (all tilde-in-code); with the fix, all 28 pass. The messages Vitest suite passes (99 files, 2944 tests), and tsc --noEmit, biome and the commit hooks are clean.

Review and validation

  • Agent review: independent fresh-context review of the diff under AGENTS.md "Reviewing"; no blocking findings (optional suggestions only: a nested-span test, a rename of one test).
  • Agent exercise of the changed behavior in the running app: skipped. Tests cover the converter, not the editor UI.
  • Human test: the author ran a developer build from this branch and confirmed that typing `~/Foo/bar` keeps the text intact; the same input loses ~ and the last character on the unfixed release build and the merge-base commit.

buzz-review-completed

🤖 Generated with Claude Code

@bwester
bwester force-pushed the fizz/fix-code-span-tilde branch from 39ba5fd to 7508a80 Compare November 8, 2026 22:59
bwester and others added 2 commits November 9, 2026 02:40
…de in code spans

Adds tests for live conversion of bold, italic, strike and code spans and for
the cases that must stay literal. Includes regression cases for code spans
whose content contains ~ (e.g. `~/Foo/bar`), which currently lose two
characters from each end. Those cases fail until the follow-up fix.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Benjamin Wester <bwester@squareup.com>
Co-authored-by: Fizz <30bc1d8f89bd966e75f929d7650e158428987f12c19aa19ece4a8b087a4aecf3@buzz.block.builderlab.xyz>
Typing the closing backtick of `~/Foo/bar` converted it to "/Foo/ba". The
span delimiter length was read with /^[`~]+/, so a ~ directly after the opening
backtick counted as delimiter and two characters were trimmed from each end.
Count only the backtick run for code spans and only ~ for strikethrough.

Introduced with live Markdown conversion in e89d48c (#455).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Benjamin Wester <bwester@squareup.com>
Co-authored-by: Fizz <30bc1d8f89bd966e75f929d7650e158428987f12c19aa19ece4a8b087a4aecf3@buzz.block.builderlab.xyz>
@bwester
bwester force-pushed the fizz/fix-code-span-tilde branch from 7508a80 to 1908627 Compare November 9, 2026 02:41
@bwester
bwester marked this pull request as ready for review November 9, 2026 03:02
@bwester
bwester requested a review from a team as a code owner November 9, 2026 03:02

@dr0uleau dr0uleau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 approved at 1908627 -- CI passes

@dr0uleau
dr0uleau merged commit 3b98f2b into block:main Nov 9, 2026
60 checks passed
@bwester
bwester deleted the fizz/fix-code-span-tilde branch November 9, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants