bubbletea icon indicating copy to clipboard operation
bubbletea copied to clipboard

Caught panic: runtime error: index out of range [3] with length 3

Open j-mnr opened this issue 2 years ago • 0 comments

:wave: Hello :smile:

While trying out some components from Bubbles I ran into an issue with the text-area component -- Full example on playground -- there were two things I noticed.

  1. When I used arrow keys the character [ would make itself appear as if I typed it in
  2. When I held down the Down arrow key a panic would happen.
Caught panic:

runtime error: index out of range [2] with length 2

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
	/usr/lib/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
	/usr/lib/go/src/runtime/debug/stack.go:16 +0x19
github.com/charmbracelet/bubbletea.(*Program).StartReturningModel.func3()
	/home/jay/.local/share/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:371 +0x95
panic({0x526000, 0xc00001b3e0})
	/usr/lib/go/src/runtime/panic.go:890 +0x262
github.com/charmbracelet/bubbles/textarea.(*Model).CursorDown(0xc00013a400)
	/home/jay/.local/share/go/pkg/mod/github.com/charmbracelet/[email protected]/textarea/textarea.go:371 +0x371
github.com/charmbracelet/bubbles/textarea.Model.Update({{0x0, 0x0}, {0xc0000181b0, 0x4}, {0x535f72, 0x13}, 0x1, 0x7e, {{{0xc00006a100, 0x2, ...}, ...}, ...}, ...}, ...)
	/home/jay/.local/share/go/pkg/mod/github.com/charmbracelet/[email protected]/textarea/textarea.go:910 +0x192c
main.model.Update({{{0x0, 0x0}, {0xc0000181b0, 0x4}, {0x535f72, 0x13}, 0x1, 0x7e, {{{...}, {...}, ...}, ...}, ...}, ...}, ...)
	/home/jay/src/go/personal/intros/bubble-tea/main.go:70 +0x40a
github.com/charmbracelet/bubbletea.(*Program).StartReturningModel(0xc00011e0b0)
	/home/jay/.local/share/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:538 +0x123f
github.com/charmbracelet/bubbletea.(*Program).Start(...)
	/home/jay/.local/share/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:547
main.main()
	/home/jay/src/go/personal/intros/bubble-tea/main.go:17 +0x8a

I'm very new to bubbletea but I'm guessing this isn't expected to happen. Here's the entire go.mod file

module shopls

go 1.19

require (
	github.com/charmbracelet/bubbles v0.14.0
	github.com/charmbracelet/bubbletea v0.21.0
)

require (
	github.com/atotto/clipboard v0.1.4 // indirect
	github.com/charmbracelet/lipgloss v0.5.0 // indirect
	github.com/containerd/console v1.0.3 // indirect
	github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
	github.com/mattn/go-isatty v0.0.14 // indirect
	github.com/mattn/go-runewidth v0.0.13 // indirect
	github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 // indirect
	github.com/muesli/cancelreader v0.2.0 // indirect
	github.com/muesli/reflow v0.3.0 // indirect
	github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect
	github.com/rivo/uniseg v0.2.0 // indirect
	golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
	golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
)

Let me know if there's anything you need to know about concerning my terminal or keyboard.

image

j-mnr avatar Sep 15 '22 01:09 j-mnr