Code block invisible line numbers fixed, QuillEditorConfig.showCodeBlockLineNumbers added - #2733
Open
Alspb wants to merge 2 commits into
Open
Code block invisible line numbers fixed, QuillEditorConfig.showCodeBlockLineNumbers added#2733Alspb wants to merge 2 commits into
Alspb wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes code-block line numbers not being visible in non-indented code blocks by reserving non-zero leading gutter width, and introduces a new QuillEditorConfig.showCodeBlockLineNumbers toggle (default true) to allow hiding code-block line numbers while shrinking the gutter.
Changes:
- Fix code-block gutter sizing so line numbers render visibly by default, and refine code-block gutter/padding dimensions.
- Add
QuillEditorConfig.showCodeBlockLineNumbersand plumb it throughQuillEditor→QuillRawEditor→EditableTextBlock. - Update changelog entries describing the new option and the layout adjustments.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/editor/widgets/text/utils/text_block_utils.dart | Fix default indent width calculation for code blocks; add right indent for code blocks. |
| lib/src/editor/widgets/text/text_block.dart | Add showCodeBlockLineNumbers handling; adjust code-block leading width/padding and optionally hide line-number leading. |
| lib/src/editor/raw_editor/raw_editor_state.dart | Pass through showCodeBlockLineNumbers; adjust code-block contentPadding. |
| lib/src/editor/raw_editor/config/raw_editor_config.dart | Add showCodeBlockLineNumbers to raw editor config. |
| lib/src/editor/editor.dart | Forward showCodeBlockLineNumbers from QuillEditorConfig into QuillRawEditorConfig. |
| lib/src/editor/config/editor_config.dart | Add showCodeBlockLineNumbers property + docs + copyWith support. |
| CHANGELOG.md | Document the new toggle and the code-block gutter/padding behavior changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+176
to
+180
| indentWidthBuilder(block, context, count, numberPointWidthBuilder); | ||
| final HorizontalSpacing horizontalSpacingForBlock; | ||
| if (isCodeBlock && !showCodeBlockLineNumbers) { | ||
| horizontalSpacingForBlock = | ||
| HorizontalSpacing(blockSpacing.right, blockSpacing.right); |
| - Tightened the code-block leading gutter: its reserved width is now slightly narrower than the ordered-list gutter (by `fontSize / 4`), pulling the right-aligned line number closer to the left edge of the block. | ||
| - Reduced the right-side padding inside the code-block leading container from `fontSize` to `fontSize / 2`, shrinking the gap between the line number and the code text to match ordered/unordered lists. | ||
| - Reduced the left content padding inside the code-block decoration from `16` to `4`, so the line number sits closer to the left edge of the grey code-block box. | ||
| - Made the code-block content padding symmetric (`EdgeInsets.symmetric(horizontal: 4, vertical: 16)`, previously `16` on the right), and added a `fontSize / 2` right indent to code blocks in `TextBlockUtils.defaultIndentWidthBuilder` so the code text no longer runs to the right edge of the box. The right indent is part of the default `indentWidthBuilder`, so a custom `indentWidthBuilder` can override it. |
Comment on lines
+72
to
75
| } else if (attrs.containsKey(Attribute.codeBlock.key)) { | ||
| baseIndent = numberPointWidthBuilder(fontSize, count) - fontSize / 4; | ||
| return HorizontalSpacing(baseIndent + extraIndent, fontSize / 2); | ||
| } |
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.
Description
fix: make code block line numbers visibleCode-block line numbers were invisible for non-indented code blocks.
Nested indent levels keep rotating the numbering style (Arabic → letters →
Roman), matching ordered-list behavior.
feat: add QuillEditorConfig.showCodeBlockLineNumbersAdds
QuillEditorConfig.showCodeBlockLineNumbers(defaulttruewhich doesn't change the current behavior) — a focused opt-out that replaces the v10QuillEditorCodeBlockElementOptions.enableLineNumbersremoved in v11.Rationale:
customLeadingBlockBuildercould already hide the line-number widget (SizedBox.shrink()), but leaves a wide blank left gutter.Type of Change