bloznelis / typioca

Cozy typing speed tester in terminal
MIT License
750 stars 22 forks source link

Crashes if you press space on the last word in a word count run. #44

Closed kothavade closed 2 years ago

kothavade commented 2 years ago

info

arch, alacritty, latest aur typioca-git

error message

Caught panic:

runtime error: slice bounds out of range [:145] with capacity 144

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
    runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
    runtime/debug/stack.go:16 +0x19
github.com/charmbracelet/bubbletea.(*Program).StartReturningModel.func3()
    github.com/charmbracelet/bubbletea@v0.20.0/tea.go:359 +0x95
panic({0x718560, 0xc0001720d8})
    runtime/panic.go:844 +0x258
main.TestBase.colorCursor(...)
    github.com/bloznelis/typioca/src/view.go:334
main.TestBase.paragraphView({{0xc0001e2000, 0x90, 0x90}, {0xc000120400, 0x90, 0x100}, {0xc000100280, 0x9, 0x10}, 0x49, ...}, ...)
    github.com/bloznelis/typioca/src/view.go:294 +0x325
main.model.View({{0x719da0, 0xc0002c4700}, {0xc0000aa3c0, 0xc0000aa3d8, 0xc0000a06f0, 0x7a24e0, 0xc0000a0700, 0xc0000a0710, 0xc0000a0720, 0xc0000a0730}, ...})
    github.com/bloznelis/typioca/src/view.go:154 +0x245
github.com/charmbracelet/bubbletea.(*Program).StartReturningModel(0xc0000e6100)
    github.com/charmbracelet/bubbletea@v0.20.0/tea.go:549 +0x1398
github.com/charmbracelet/bubbletea.(*Program).Start(...)
    github.com/charmbracelet/bubbletea@v0.20.0/tea.go:556
main.glob..func1(0x9ba360?, {0x73300a?, 0x0?, 0x0?})
    github.com/bloznelis/typioca/src/main.go:56 +0x1ca
github.com/spf13/cobra.(*Command).execute(0x9ba360, {0xc0000981f0, 0x0, 0x0})
    github.com/spf13/cobra@v1.4.0/command.go:856 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0x9ba360)
    github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.4.0/command.go:902
main.main()
    github.com/bloznelis/typioca/src/main.go:125 +0x25
bye!

reproduce

start a word count run, and on the last word, press space instead of the last letter.

bloznelis commented 2 years ago

Thanks for reporting ! Fixed by https://github.com/bloznelis/typioca/pull/45