Skip to content

More straightforward newline handling#241

Open
tempoz wants to merge 1 commit into
buildkite:mainfrom
buildbuddy-io:consistent-newlines
Open

More straightforward newline handling#241
tempoz wants to merge 1 commit into
buildkite:mainfrom
buildbuddy-io:consistent-newlines

Conversation

@tempoz
Copy link
Copy Markdown
Contributor

@tempoz tempoz commented Aug 13, 2025

This PR ensures that every newline: true corresponds to an actual newline character, and conversely that every newline character has a newline: true field somewhere.

This:

  • Lets us distinguish between an input that ends with a newline and one that does not on render
  • Allows us to render input that ends with multiple newlines correctly
  • Allows us to scroll out one line at a time, which greatly simplifies the scroll out logic
  • Eliminates the awkward new line that would appear in the middle of a line when scrolling out a line that was too large for the window (see huge-line.sh)

@tempoz
Copy link
Copy Markdown
Contributor Author

tempoz commented Sep 5, 2025

Hey, just checking in on the status of this PR since I have another one I would like to submit that stacks on this one :D

@DrJosh9000
Copy link
Copy Markdown
Contributor

Thanks @tempoz, I'm a bit busy lately, haven't been able to give this the time it deserves. From a quick skim this looks good though. I'll aim to do a proper review this week.

@tempoz
Copy link
Copy Markdown
Contributor Author

tempoz commented Sep 8, 2025

No problem; I greatly appreciate your time and consideration whenever you have the bandwidth to give it.

Copy link
Copy Markdown
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

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

Apologies for the delay in getting around to it, but this looks great! Thanks!

@DrJosh9000
Copy link
Copy Markdown
Contributor

Would you mind rebasing this / merging from main? I would do it if GitHub showed me the button (I probably don't have rights to make changes directly to your repo.)

@tempoz tempoz force-pushed the consistent-newlines branch from 1edadd9 to abd2508 Compare January 30, 2026 00:22
@tempoz
Copy link
Copy Markdown
Contributor Author

tempoz commented Jan 30, 2026

done!

@philwo
Copy link
Copy Markdown

philwo commented Jan 31, 2026

Hi!

I noticed that the first line rendered into the screen gets truncated under circumstances that I'm not fully sure yet how to describe... but I found an easy minimal repro that I'm curious what you both think about:

  • Check out the latest main of terminal-to-html.
  • Comment out or remove the line screen.ScrollOutFunc = wc.WriteString in cmd/terminal-to-html/terminal-to-html.go.
  • Run the following command and observe the output. Note that the "hello world" line is 82 chars long:
$ go build cmd/terminal-to-html
$ for i in $(seq -w 0 50); do echo "[$i] hello world hello world hello world hello world hello world hello world hello"; done | \
  ./terminal-to-html --window-max-cols=80 --buffer-max-lines=50 --window-cols=80 --window-lines=50

[26] hello world hello world hello world hello world hello world hello world hello
[27] hello world hello world hello world hello world hello world hello world hello
[28] hello world hello world hello world hello world hello world hello world hello
[29] hello world hello world hello world hello world hello world hello world hello
[30] hello world hello world hello world hello world hello world hello world hello
[31] hello world hello world hello world hello world hello world hello world hello
[32] hello world hello world hello world hello world hello world hello world hello
[33] hello world hello world hello world hello world hello world hello world hello
[34] hello world hello world hello world hello world hello world hello world hello
[35] hello world hello world hello world hello world hello world hello world hello
[36] hello world hello world hello world hello world hello world hello world hello
[37] hello world hello world hello world hello world hello world hello world hello
[38] hello world hello world hello world hello world hello world hello world hello
[39] hello world hello world hello world hello world hello world hello world hello
[40] hello world hello world hello world hello world hello world hello world hello
[41] hello world hello world hello world hello world hello world hello world hello
[42] hello world hello world hello world hello world hello world hello world hello
[43] hello world hello world hello world hello world hello world hello world hello
[44] hello world hello world hello world hello world hello world hello world hello
[45] hello world hello world hello world hello world hello world hello world hello
[46] hello world hello world hello world hello world hello world hello world hello
[47] hello world hello world hello world hello world hello world hello world hello
[48] hello world hello world hello world hello world hello world hello world hello
[49] hello world hello world hello world hello world hello world hello world hello
[50] hello world hello world hello world hello world hello world hello world hello%
  • Patch in this PR and try again. Note that the first line printed is now truncated to "lo", while the same line number was still fully printed in the previous run:
$ go build cmd/terminal-to-html
$ for i in $(seq -w 0 50); do echo "[$i] hello world hello world hello world hello world hello world hello world hello"; done | \
  ./terminal-to-html --window-max-cols=80 --buffer-max-lines=50 --window-cols=80 --window-lines=50

lo
[27] hello world hello world hello world hello world hello world hello world hello
[28] hello world hello world hello world hello world hello world hello world hello
[29] hello world hello world hello world hello world hello world hello world hello
[30] hello world hello world hello world hello world hello world hello world hello
[31] hello world hello world hello world hello world hello world hello world hello
[32] hello world hello world hello world hello world hello world hello world hello
[33] hello world hello world hello world hello world hello world hello world hello
[34] hello world hello world hello world hello world hello world hello world hello
[35] hello world hello world hello world hello world hello world hello world hello
[36] hello world hello world hello world hello world hello world hello world hello
[37] hello world hello world hello world hello world hello world hello world hello
[38] hello world hello world hello world hello world hello world hello world hello
[39] hello world hello world hello world hello world hello world hello world hello
[40] hello world hello world hello world hello world hello world hello world hello
[41] hello world hello world hello world hello world hello world hello world hello
[42] hello world hello world hello world hello world hello world hello world hello
[43] hello world hello world hello world hello world hello world hello world hello
[44] hello world hello world hello world hello world hello world hello world hello
[45] hello world hello world hello world hello world hello world hello world hello
[46] hello world hello world hello world hello world hello world hello world hello
[47] hello world hello world hello world hello world hello world hello world hello
[48] hello world hello world hello world hello world hello world hello world hello
[49] hello world hello world hello world hello world hello world hello world hello
[50] hello world hello world hello world hello world hello world hello world hello%

I'm not sure what the correct fix for this - any idea?

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.

3 participants