Closed viperperidot closed 3 years ago
I'm not able to replicate this issue. Does it happen every time the window is resized to full screen? Do resizes in general also cause it to occur?
Yes it happens every time the window is resized, currently I can only use ticker in the size that the terminal launches in otherwise I will get the panic. Yes any resize causes this, even a drag one.
It might be caused by the width of each cell being negative for some reason during a window resize event. I added handling for this - have a look at the latest version and let me know if that fixed it.
Unfortunately this update did not fix it..
Any chance you'd be open to trying it in a VM? This would help isolate the issue. If the issue occurs in the VM that great then I can try replicating it on my end with the same setup. If not then it's possible it's a hardware issue of some kind.
Since I can not replicate the issue, it's any fix I attempt would be a shot in a dark.
I am not using a VM, but I can say that it was introduced in the previous version, I have been able to resize the window successfully prior to this.
Would you be open to sharing your OS + version and terminal + version?
Ubuntu 20.04.2 LTS
GNOME Terminal 3.36.2
I'm seeing similar behavior in macOS 10.15.7, zsh 5.7.1. If I try to launch ticker at my default size of 120x40, it throws that out of range error, but if I resize my terminal so it's not so wide it works correctly.
120 columns seems to be the threshold where it's broken for me.
@MisterCubanSandwich that's very helpful information. Are saying if the terminal window exceeds 120 columns the error is thrown? @viperperidot does resizing below 120 also work okay for you?
Correct, it immediately crashes if launched or resized to wider than 120. I can resize it just fine if I keep it narrower than that.
@MisterCubanSandwich would you mind sharing the error message? It would be helpful to understand if it is the exact same issue or a variant
@achannarasappa I just tested my threshold and for me I get the error kicking in at 105 column width.
Here's the error I get on my Mac:
Caught panic:
runtime error: slice bounds out of range [:-3]
Restoring terminal...
goroutine 1 [running]:
runtime/debug.Stack(0x56, 0x0, 0x0)
/opt/hostedtoolcache/go/1.15.8/x64/src/runtime/debug/stack.go:24 +0x9f
runtime/debug.PrintStack()
/opt/hostedtoolcache/go/1.15.8/x64/src/runtime/debug/stack.go:16 +0x25
github.com/charmbracelet/bubbletea.(*Program).Start.func1(0xc000153080)
/home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.12.2/tea.go:119 +0xd3
panic(0x1560da0, 0xc00029d020)
/opt/hostedtoolcache/go/1.15.8/x64/src/runtime/panic.go:969 +0x1b9
github.com/achannarasappa/term-grid.getLineText(0x0, 0xc00031c650, 0x1, 0x1, 0x1, 0xfffffffffffffffd, 0x0, 0x1, 0x1)
/home/runner/go/pkg/mod/github.com/achannarasappa/term-grid@v0.2.0/cell.go:40 +0x251
github.com/achannarasappa/term-grid.getLines(0x0, 0x0, 0xfffffffffffffffd, 0x0, 0x0, 0x0, 0xc00000c3c0, 0x2, 0x2, 0x2, ...)
/home/runner/go/pkg/mod/github.com/achannarasappa/term-grid@v0.2.0/cell.go:74 +0x2d7
github.com/achannarasappa/term-grid.renderRow(0x79, 0xc000262000, 0x9, 0x9, 0x1, 0xc00003d680, 0x0)
/home/runner/go/pkg/mod/github.com/achannarasappa/term-grid@v0.2.0/row.go:81 +0x1ad
github.com/achannarasappa/term-grid.Render(0xc000132000, 0x6, 0x8, 0x0, 0x1, 0xc000152e40, 0x15c5318)
/home/runner/go/pkg/mod/github.com/achannarasappa/term-grid@v0.2.0/grid.go:29 +0xcc
github.com/achannarasappa/ticker/internal/ui/component/watchlist.Model.View(0x79, 0xc00051c280, 0x2, 0x2, 0xc0000685a0, 0x10101, 0x15c52e8, 0x5, 0xc0000a6b00, 0x2, ...)
/home/runner/work/ticker/ticker/internal/ui/component/watchlist/watchlist.go:85 +0x33a
github.com/achannarasappa/ticker/internal/ui.Model.Update(0x5, 0xc0000a6b00, 0x2, 0x2, 0x0, 0x0, 0x0, 0x10101, 0x0, 0x0, ...)
/home/runner/work/ticker/ticker/internal/ui/ui.go:114 +0x765
github.com/charmbracelet/bubbletea.(*Program).Start(0xc000153080, 0x0, 0x0)
/home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.12.2/tea.go:214 +0x61c
github.com/achannarasappa/ticker/internal/ui.Start.func1(0xc000152a80, 0xc000152b70)
/home/runner/work/ticker/ticker/internal/ui/start.go:14 +0x1a5
github.com/achannarasappa/ticker/internal/cli.Run.func1(0x1906e60, 0x1941c48, 0x0, 0x0)
/home/runner/work/ticker/ticker/internal/cli/cli.go:36 +0x2a
github.com/spf13/cobra.(*Command).execute(0x1906e60, 0xc00008e1b0, 0x0, 0x0, 0x1906e60, 0xc00008e1b0)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:854 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x1906e60, 0x1044aaa, 0x18be180, 0xc000038778)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
Thanks @viperperidot and @MisterCubanSandwich this info is really helpful. I'll take a shot at replicating the error
Thanks for the details @viperperidot and @MisterCubanSandwich. I've put out a fix in release v4.0.4 that I believe addresses the issue. The root cause was that the width of the fixed width cells sometimes exceeded with width of the row which cause the error both of you observed. I've added better handling for this condition now and hopefully it will work as expected. When you have a chance take a look and let me know if the issue still occurs (and if it does please reshare the new error).
Good news is I can now replicate the bug, bad news is that the bug is not fixed :)
It seems to occur on window resize frequently enough to be annoying but not on every resize. I'll keep at a fix
Thanks for the comment @spsx ! I'll close this issue but do reopen if the issue still resurfaces
When I start ticker and then maximize the window I get this panic: