Skip to content

Add editor column guide controls#422

Open
yusufm wants to merge 1 commit into
schuyler:mainfrom
yusufm:Codex/add-editor-column-guide-019def52-b3da-7962-96cd-afa05d8d1592
Open

Add editor column guide controls#422
yusufm wants to merge 1 commit into
schuyler:mainfrom
yusufm:Codex/add-editor-column-guide-019def52-b3da-7962-96cd-afa05d8d1592

Conversation

@yusufm

@yusufm yusufm commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add View menu controls for showing a column guide and wrapping at it
  • support 80, 100, and 120 column guide widths
  • persist guide/wrap preferences and draw the guide in the editor

Tests

  • xcodebuild test -workspace "MacDown 3000.xcworkspace" -scheme MacDown -only-testing:MacDownTests/MPPreferencesTests -only-testing:MacDownTests/MPEditorViewSubstitutionTests -destination 'platform=macOS'\n\nRelated to Add configurable column width/wrapping option #44

@schuyler schuyler left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @yusufm!

The shape here is solid — prefs, a guide drawn in drawViewBackgroundInRect:, optional hard-wrap, and a View › Column Guide submenu. The wrap path is where most of the risk is.

Issues

  • Monospace assumption. Both the guide position (columnGuideXPosition) and the wrap width derive from the advance width of "0" × columns. That only aligns for a fixed-pitch font; MacDown lets users pick any editor font, so with a proportional font the guide line and wrap point drift from the real character column.
  • Guide line vs. wrap point diverge. columnGuideXPosition includes textContainerOrigin.x (the inset), but the wrap container width in applyColumnGuidePreferences is charWidth*column + 2*padding with no inset term, so when wrapping is on the drawn line and the actual wrap boundary won't coincide.
  • Interaction with existing width-limiting. applyColumnGuidePreferences hard-sets widthTracksTextView and containerSize in both branches. MacDown already manages editor width via editorWidthLimited/editorMaximumWidth + adjustEditorInsets; forcing the container to {CGFLOAT_MAX, CGFLOAT_MAX} when wrap is off can stomp that. Worth confirming width-limited + wrap-at-guide compose.
  • Horizontal scrolling/clipping. With widthTracksTextView = NO and a fixed container wider than the viewport, the text view/scroll view needs to be horizontally resizable or text will clip. Is that configured?

Suggestions

  • The new menu titles (Show Column Guide, Wrap at Column Guide, 80/100/120 Columns) aren't in Localizable.strings.
  • Test gap: the tests cover columnGuideXPosition and the clamp, but not the wrap-mode container sizing — the riskiest part is currently unexercised.
  • applyColumnGuidePreferences runs twice within one setupEditor: pass (inset branch + end of setup); collapsing to once would avoid the double work.
  • Only 80/100/120 are reachable from the menu, but editorColumnGuideWidth accepts any integer — consider whether to constrain it.

Generated by Claude Code

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.

2 participants