Give typed text the body style when nothing neighbours it - #97
Merged
Conversation
Typed text adopts the styles of the character next to the caret. Where there is none, it carried no style at all and rendered at the host's bare TextStyle size rather than the document's body size. That is not a rare edge: paragraphs are separated by a blank line, so every paragraph after the first starts at column 0 with an empty line above it. Any new paragraph, list or otherwise, came out at the default size while the imported text around it stayed correct. Markdown and HTML editors now fall back to the configured defaultTextStyle. Plain editors opt out via hasMarkdownConfiguration so their typed text is still left to the host's TextStyle.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 10 |
| Duplication | 2 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This was referenced Aug 7, 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.
The bug
Typed text adopts the styles of the character next to the caret: the one before it, or the one it sits in front of. When neither exists,
getSpanStylesForEditAtreturned nothing, so the text carried noSpanStyleat all and rendered at the host's bareTextStylesize instead of the document's body size.That is not a rare edge case. Paragraphs are separated by a blank line, so every paragraph after the first starts at column 0 with an empty line above it: no preceding character, and none in front either. Any newly typed paragraph came out at the default size while the imported text around it stayed correct.
Found in Hammer, which passes
TextStyle.Defaultas the editor style and carries the real (user-scalable) font size as a span on every character. A list typed between two loaded paragraphs rendered noticeably smaller than the prose around it.The fix
When nothing neighbouring supplies a style, fall back to
markdownConfiguration.defaultTextStyle.That configuration is only meaningful once a markdown or HTML extension installs it, so
TextEditorStatenow tracks whether that happened. A plain editor never opts in and keeps the previous behaviour: its typed text is left to the host'sTextStylerather than being stamped with a 16sp body style it never asked for.Tests
TypedTextBodyStyleTestcovers a paragraph typed after a blank line, a list typed after a blank line, typing into an empty document, a neighbouring style still winning over the fallback, and a plain editor staying untouched.Full
:ComposeTextEditor:desktopTestpasses.