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

[completer] Fix bug which causes integer divide by zero panicking when input buffer is empty #54

Merged
merged 2 commits into from
May 9, 2016

Conversation

antekresic
Copy link
Contributor

@antekresic antekresic commented May 9, 2016

Fixes issue #53

@antekresic antekresic changed the title [completer] Fixes issue #53 [completer] Fix bug which causes integer divide by zero panicking when input buffer is empty May 9, 2016
@@ -66,7 +66,7 @@ func (o *opCompleter) OnComplete() {
buf := o.op.buf
rs := buf.Runes()

if o.IsInCompleteMode() && runes.Equal(rs, o.candidateSource) {
if o.IsInCompleteMode() && len(rs) > 0 && runes.Equal(rs, o.candidateSource) {
Copy link
Owner

@chzyer chzyer May 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use runes.Equal(rs, o.candidateSource) here is want to indicate whether user press twice <tab>.
o.candidateSource will be set to nil when o.ExitCompleteSelectMode() is called.
The problem is that runes.Equal([], nil) is still true.
So I suggests that change len(rs) > 0 to o.candidateSource != nil

@chzyer
Copy link
Owner

chzyer commented May 9, 2016

Just to mention, the user who submit the commit is not a valid github user :)
Would you want to set it to your github account ?

@antekresic
Copy link
Contributor Author

Updated the PR and, hopefully, fixed the user.

Thanks for the heads up!

@chzyer chzyer merged commit dc15d0f into chzyer:master May 9, 2016
@chzyer
Copy link
Owner

chzyer commented May 9, 2016

👍

lunixbochs pushed a commit to lunixbochs/readline that referenced this pull request 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

Successfully merging this pull request may close these issues.

2 participants