chriswalz / bit

Bit is a modern Git CLI
Apache License 2.0
6.05k stars 106 forks source link

bit crash on macOS #91

Closed Hultner closed 3 years ago

Hultner commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Start bit
  2. Jump around between completeions with arrow keys, quickly
  3. Sudden crash
  4. See error in stack trace

Expected behavior No crash.

Screenshots If applicable, add screenshots to help explain your problem. N/A, See stack trace.

Desktop (please complete the following information):

Additional context (Add any other context about the problem here) Stack trace

> > bit commit --amend --no-edit?[A?[Aruntime error: index out of range [0] with length 0
goroutine 1 [running]:
runtime/debug.Stack(0x16a7180, 0xc000010018, 0xc0000bd160)
        runtime/debug/stack.go:24 +0x9f
github.com/chriswalz/bit/cmd.HandleExit()
        github.com/chriswalz/bit/cmd/util.go:299 +0xd9
panic(0x15a3000, 0xc0003e2180)
        runtime/panic.go:969 +0x1b9
github.com/c-bata/go-prompt.(*CompletionManager).GetSelectedSuggestion(0xc000230000, 0xc00008a000, 0xc000230000, 0x22, 0x0, 0x26)
        github.com/c-bata/go-prompt@v0.2.5/completion.go:51 +0x108
github.com/c-bata/go-prompt.(*Render).Render(0xc000220d00, 0xc00008a000, 0xc000230000)
        github.com/c-bata/go-prompt@v0.2.5/render.go:207 +0x3bb
github.com/c-bata/go-prompt.(*Prompt).Input(0xc000232000, 0x0, 0x0)
        github.com/c-bata/go-prompt@v0.2.5/prompt.go:261 +0x4e5
github.com/c-bata/go-prompt.Input(0x15e3314, 0x6, 0xc000214090, 0xc0000bd7b0, 0xf, 0xf, 0xc12fbb6b8425fc18, 0x1579020)
        github.com/c-bata/go-prompt@v0.2.5/shortcut.go:16 +0xd6
github.com/chriswalz/bit/cmd.SuggestionPrompt(0x15e3314, 0x6, 0xc000214090, 0xc0000bd898, 0xc0000bd8c0)
        github.com/chriswalz/bit/cmd/util.go:250 +0x5aa
github.com/chriswalz/bit/cmd.glob..func5(0x199f3c0, 0x19d6558, 0x0, 0x0)
        github.com/chriswalz/bit/cmd/rootShell.go:22 +0x88
github.com/spf13/cobra.(*Command).execute(0x199f3c0, 0xc0000201d0, 0x0, 0x0, 0x199f3c0, 0xc0000201d0)
        github.com/spf13/cobra@v1.1.1/command.go:854 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x199f3c0, 0x600, 0x0, 0x0)
        github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.1.1/command.go:895
github.com/chriswalz/bit/cmd.Execute()
        github.com/chriswalz/bit/cmd/rootShell.go:100 +0x31
main.bitcli(...)
        github.com/chriswalz/bit/main.go:78
main.main()
        github.com/chriswalz/bit/main.go:66 +0x94b

OS: darwin amd64
bit version v0.8.0
git version 2.26.2
chriswalz commented 3 years ago

PR on go-prompt https://github.com/c-bata/go-prompt/pull/211