Skip to content

fix(parser): keep gutter one segment per rune when padding blank graph lines - #722

Merged
baggiiiie merged 1 commit into
idursun:mainfrom
shuvamk:fix/parser-gutter-blank-line
Aug 13, 2026
Merged

fix(parser): keep gutter one segment per rune when padding blank graph lines#722
baggiiiie merged 1 commit into
idursun:mainfrom
shuvamk:fix/parser-gutter-blank-line

Conversation

@shuvamk

@shuvamk shuvamk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Parsing the shipped fixture test/testdata/single-line-with-description.log (a commit followed by a blank graph line, as builtin_log_comfortable emits) and extending the row drops two gutter columns:

rows[0].Extend()  actual "│"   (1 segment)
                  expected "│  " (3 segments, row.Indent == 3)

Downstream, that shifts every embedded operation panel (details file list, inline describe, evolog, rebase preview) two columns to the left of the row's own text under a comfortable template.

Cause

GraphRowLine.chop first splits the gutter into one segment per rune, then pads short lines up to the row indent. The padding step re-fattened the last segment's .Text with strings.Repeat(" ", indent), undoing the per-rune split. Row.Extend() derives its mask from the gutter's segment count, so a blank line reporting 1 segment instead of 3 loses the trailing columns.

Fix

Pad by appending one single-space screen.Segment per remaining indent column, each carrying the last gutter segment's Style, so the one-rune-per-segment invariant holds.

Test

TestParser_Parse_ExtendBlankGraphLine in test/log_parser_test.go extends the fixture row and asserts the gutter is "│ ". I verified it fails without the source change (actual "│" vs expected "│ ") and passes with it.

go test ./... is green.

…h lines

A row whose graph column contains a blank line (e.g. the empty "│" line
under a commit in `builtin_log_comfortable`) has its gutter padded to the
row's indent by re-fattening the last gutter segment's text with spaces.
That breaks the one-rune-per-segment invariant `row.go` relies on:
`Row.Extend()` builds its mask from the segment count, so a padded gutter
that reports 1 segment instead of 3 loses the trailing columns.

Parsing `test/single-line-with-description.log` and extending its row:
  actual   "│"   (1 segment)
  expected "│  " (3 segments, row.Indent == 3)

The missing columns shift every embedded operation panel (details file
list, inline describe, evolog, rebase preview) two columns left of the
row's own text under a comfortable template.

Pad by appending single-space segments carrying the last gutter segment's
style, one per remaining indent column, preserving the invariant.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@shuvamk
shuvamk requested a review from idursun as a code owner August 4, 2026 00:13

@baggiiiie baggiiiie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm, thanks!
btw for such UI fixes, it'd be better to include screenshots to show what the issue was and the fixed UI

@baggiiiie
baggiiiie merged commit a052016 into idursun:main Aug 13, 2026
4 checks passed
@baggiiiie

Copy link
Copy Markdown
Collaborator

merging this, repro and results:

before

before.mp4

after

after.mp4

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