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

Panic on deleting first char in select mode #53

Closed
antekresic opened this issue May 9, 2016 · 1 comment
Closed

Panic on deleting first char in select mode #53

antekresic opened this issue May 9, 2016 · 1 comment

Comments

@antekresic
Copy link
Contributor

There is a specific case when you delete the first character in select mode, library panics out:

`> panic: runtime error: integer divide by zero
[signal 0x8 code=0x7 addr=0x5958e pc=0x5958e]

goroutine 6 [running]:
panic(0x1306a0, 0xc82000a0b0)
/usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6
gopkg.in/readline%2ev1.(_opCompleter).doSelect(0xc820084080)
/go/src/gopkg.in/readline.v1/complete.go:49 +0xee
gopkg.in/readline%2ev1.(_opCompleter).OnComplete(0xc820084080)
/go/src/gopkg.in/readline.v1/complete.go:72 +0x1e6
gopkg.in/readline%2ev1.(*Operation).ioloop(0xc820060300)
/go/src/gopkg.in/readline.v1/operation.go:172 +0x1439
created by gopkg.in/readline%2ev1.NewOperation
/go/src/gopkg.in/readline.v1/operation.go:67 +0x42a`

Here is a gist of what I'm using to test this:
https://gist.github.com/antekresic/283106411e826f53799fa4565e90f094

Steps to reproduce: press 's', Tab, Tab, Backspace

Issue seems to be caused by entering OnComplete for an empty input rune buffer. My fix suggestion is to add a check for the empty buffer here:
https://github.com/chzyer/readline/blob/master/complete.go#L69

Let me know if you want a PR.

Thanks!

@chzyer
Copy link
Owner

chzyer commented May 9, 2016

Nice catch, Thanks! And PR is welcome :)

antekresic pushed a commit to antekresic/readline that referenced this issue May 9, 2016
chzyer pushed a commit that referenced this issue May 9, 2016
…n input buffer is empty (#54)

* [completer] Fixes issue #53

* Changing check to candidateSource
@chzyer chzyer closed this as completed May 9, 2016
lunixbochs pushed a commit to lunixbochs/readline that referenced this issue May 4, 2017
…n input buffer is empty (chzyer#54)

* [completer] Fixes issue chzyer#53

* Changing check to candidateSource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants