fix(lists): indent list items and hang their wrapped lines - #17
Merged
Conversation
List items rendered as a plain paragraph whose only indentation was leading spaces. NSTextView's default paragraph style has zero head indents, so a wrapped item's continuation lines fell back to the marker's own margin — bullets, numbers, checkboxes and body text all shared one left edge. Items now carry an AppKit paragraph style: a 16pt gutter in front of the marker, and a headIndent of gutter + the typeset width of the item's prefix so continuation lines hang under the item text. The width is measured from the actual marker, so "10." hangs further than "1.", and both follow ⌘+ / ⌘-. Bullets, ordered items and task checkboxes all go through it. Also fixes the nesting level, which was ceil(columns / 4) and put a 2-space-nested child on its parent's margin. Now one level per two columns (one per tab), capped at 8, so 2- and 4-space documents both keep every level distinct. Nesting stays in the characters as well as the paragraph style: the print/PDF pipeline renders text blocks through SwiftUI Text, which ignores NSParagraphStyle, so it keeps today's space-based nesting and simply degrades to flush-left wrapping. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
|
Merged - beautiful work. The hanging indent measured from the actual marker width (so "10." hangs further than "1."), the one-level-per-two-columns nesting that keeps both 2-space and 4-space documents distinct, and the zoom-aware indents all show real care. Special credit for documenting the NSParagraphStyle exception to the dual-scope rule and keeping nesting in the characters so the print/PDF pipeline degrades gracefully - both of those saved me review questions. Verified: all 7 new tests green, full suite passes, wrapped items confirmed hanging correctly in a running build. Ships in v1.7.0. Two great fixes in one evening - thank you! |
Owner
|
v1.7.0 with this change is now live: https://github.com/b451c/quickmd/releases/tag/v1.7.0 - thanks again! |
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.
List items rendered as a plain paragraph whose only indentation was leading spaces. NSTextView's default paragraph style has zero head indents, so a wrapped item's continuation lines fell back to the marker's own margin — bullets, numbers, checkboxes and body text all shared one left edge.
Items now carry an AppKit paragraph style: a 16pt gutter in front of the marker, and a headIndent of gutter + the typeset width of the item's prefix so continuation lines hang under the item text. The width is measured from the actual marker, so "10." hangs further than "1.", and both follow ⌘+ / ⌘-. Bullets, ordered items and task checkboxes all go through it.
Also fixes the nesting level, which was ceil(columns / 4) and put a 2-space-nested child on its parent's margin. Now one level per two columns (one per tab), capped at 8, so 2- and 4-space documents both keep every level distinct.
Nesting stays in the characters as well as the paragraph style: the print/PDF pipeline renders text blocks through SwiftUI Text, which ignores NSParagraphStyle, so it keeps today's space-based nesting and simply degrades to flush-left wrapping.