Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewport: last line of content not rendered when scrolling if it doesn't end with new line \n #73

Closed
MarcoLucidi01 opened this issue Sep 16, 2021 · 2 comments · Fixed by #74
Labels
bug Something isn't working

Comments

@MarcoLucidi01
Copy link

hello, I come from a project (ticker) that uses bubbles/viewport to display its main contents.

we noticed that when the content doesn't fit on a single page and you scroll at the bottom, bubbles/viewport doesn't render the last line of content if it doesn't end with a new line \n character (here the issue #158 reported on ticker).

the problem is reproducible with bubbletea's pager example that uses bubbles/viewport, for example:

$ git clone https://github.com/charmbracelet/bubbletea.git
...
$ cd bubbletea/examples/pager/
$ go build
$ ls -1
artichoke.md    # file displayed in the example
main.go
pager*
$ tail -1 artichoke.md | xxd | tail -1
00000030: 2069 6e20 5370 616e 6973 682e 0a          in Spanish..    # ends with new line
$ ./pager
lastline.mp4

everything looks fine, now I remove last new line \n character from artichoke.md:

$ truncate -s -1 artichoke.md
$ tail -1 artichoke.md | xxd | tail -1
00000030: 2069 6e20 5370 616e 6973 682e             in Spanish.
$ ./pager
nolastline.mp4

and the last line

_Alcachofa_, if you were wondering, is artichoke in Spanish.

is not displayed anymore.

unfortunately I don't have a patch, I suspect it's an off-by-one error because I see lots of len(m.lines)-1 in viewport.go and I think it could be related to the problem, but I wasn't able to completely figure it out.

@meowgorithm meowgorithm added the bug Something isn't working label Sep 16, 2021
@meowgorithm
Copy link
Member

Noted, thanks for the report. I suspect you’re right about the off-by-one error, but we’ll take a look.

@meowgorithm
Copy link
Member

This is now fixed in master and will be available in the next release. Thank you very much for the thorough report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants