Repository navigation
Stop Markdown inserting a space where inline runs touch [patch] - #642
Merged
Merged
Conversation
InlineLayout.Wrap put a space before every token but the first on a line, so the run boundaries an emphasis, inline code or link creates drew as gaps: "**Note**:" became "Note :" and "[docs](u)." became "docs .". Wrap now groups tokens with no source whitespace between them, across runs, into one word that gets no inner spacing and wraps as a unit, so a line can no longer break inside a glued sequence. Fixes #480 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Cibp2qAPg69KcG7TXtUeH
SonarCloud flagged SplitGluedWords at cognitive complexity 19. The whitespace tracking moves into Tokenize, which yields each token with a space-before flag, and SplitGluedWords only groups. Tokenize also skips an empty text run, which would otherwise have read as whitespace and split the runs either side of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Cibp2qAPg69KcG7TXtUeH
|
This was referenced Oct 17, 2026
This was referenced Oct 19, 2026
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.



Fixes #480
What
InlineLayout.WrapaddedspaceWidthbefore every token except the first on a line. Emphasis, inline code and links each split the text into separate runs, so a gap appeared at every one of those boundaries:**Note**: textNote : textNote: text`a`ba bab[docs](u).docs .docs.a**b**ca b cabcChange
Tokenizewalks all the runs and flags each token that had whitespace before it in the source: a space inside the run, at the end of the previous run, or at the start of this one. The soft-break" "run counts as whitespace. An empty run is skipped, so it doesn't look like a space. Images follow the same rule.SplitGluedWordsgroups the flagged tokens into words.Wrapplaces one word at a time. It measures the whole word, adds a space only between words, and breaks lines only between words, so a line can no longer break betweendocsand its.. Each token keeps its own role and link, so fonts and link hit-tests are unchanged.This doesn't address hard line breaks (#481), which are tracked separately.
Tests
tests/ImGui.Markdown.Tests/InlineLayoutTests.csgets seven new tests:**x**:,`a`b,[l](u).anda**b**ceach check the token x positions, which no longer contain a phantom space."ab ","cd"," ef") still separates tokens. This guards against over-gluing.aaa docsbut notaaa docs.,docs.moves to the next line together.I restored the original
InlineLayout.csand ran the tests again: the boundary tests fail and the whitespace guard passes. With the fix,ImGui.Markdown.Testspasses 49/49. CI is green on all three OSes, includingImGuiMarkdownDemo.UITests. Those demo tests fail locally only because this container gets the image assets as Git LFS pointer stubs.🤖 Generated with Claude Code
https://claude.ai/code/session_018Cibp2qAPg69KcG7TXtUeH