Skip to content

fix: start code lines with a partially consumed tab in their own source line (DEV-3358) - #24

Merged
Yukaii merged 3 commits into
masterfrom
fix/dev-3358-src-line-starts
Nov 18, 2026
Merged

Yukaii merged 3 commits into
masterfrom
fix/dev-3358-src-line-starts

Conversation

@galaxian85

Copy link
Copy Markdown

Fixes the P2 item from DEV-3267: with tabs, meta.srcLineStarts on fence and code_block was not always a real line start (>\t\tfoo gave [-1]; in - a\n\n ```\n\tfoo\n ``` the start pointed into the previous line).

Changes

  • srcLineStarts[k] is now always the source offset of the first character of line k. With S = srcLineStarts[k], z = indentZwsp[k], p = srcLinePads[k] and t = S + 1 if p > 0 && z === 0, else t = S + z:
    • U+200B (c < z) → S + c
    • padding (c < z + p) → the tab, at t - 1
    • text → t + c - z - p
    • lines without padding are unchanged (S + c)
  • Tests: assertRealLineStarts (non-negative, increasing, first character maps back, never crosses a newline) runs on every code test, including the 400 random cases, plus a regression test.

This changes the meaning of a published field, so it should go out as 14.2.0. hackmd-production's codeSourceMap.ts must be updated in the same release; updating only one side makes positions worse than today.

CHANGELOG

The second commit splits [14.2.0] - Unreleased, most of which already shipped:

  • Dates of 14.1.1–14.1.3 come from the npm registry (UTC). Their contents come from matching each npm tarball's lib/ with git: 14.1.1 = 3887153, 14.1.2 = e5437e7, 14.1.3 = cdc762f (fix: accurate source positions in containers and code blocks #22).
  • Adds three 14.1.3 changes listed in DEV-3267 as missing: the text_join join condition, getLineOffset(state, line), and the StateInline line API.
  • [14.2.0] keeps only this fix. The bump-version workflow doesn't touch the CHANGELOG, so set its date when releasing.

Test

npm test: 1620 passing, lint and build pass.

🤖 Generated with Claude Code

@galaxian85

Copy link
Copy Markdown
Author

14.2.0 的 release date 要麻煩 @Yukaii commit 了

@coveralls

coveralls commented Nov 18, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 44255971129

Coverage remained the same at 99.336%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 23 of 23 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 6673
Covered Lines: 6640
Line Coverage: 99.51%
Relevant Branches: 1767
Covered Branches: 1744
Branch Coverage: 98.7%
Branches in Coverage %: Yes
Coverage Strength: 390937.39 hits per line

💛 - Coveralls

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Yukaii
Yukaii force-pushed the fix/dev-3358-src-line-starts branch from 4033c31 to b8ee496 Compare November 18, 2026 07:03
@Yukaii
Yukaii merged commit 6a2decf into master Nov 18, 2026
2 checks passed
@Yukaii
Yukaii deleted the fix/dev-3358-src-line-starts branch November 18, 2026 07:04
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.

3 participants