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

Ensure correctness while typing a query fast #270

Merged
merged 2 commits into from
Dec 30, 2017
Merged

Ensure correctness while typing a query fast #270

merged 2 commits into from
Dec 30, 2017

Conversation

mptre
Copy link
Owner

@mptre mptre commented Dec 30, 2017

Typing a query fast enough to trigger the poll check in filter_choices()
could yield a wrong set of choices. Since filter_choices() is
interrupted, all choices have yet not been examined and potential
matches could still be left unexamined. Calling print_choices() in this
state causes the unexamined choices to never be reconsidered as
potential matches since they will have a score = 0. The solution is to
never call print_choices() if filter_choices() was interrupted.

Problem reported and partial solution provided by Jenz Guenther in
GitHub issue #268.

@codecov-io
Copy link

codecov-io commented Dec 30, 2017

Codecov Report

Merging #270 into master will decrease coverage by 0.21%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #270      +/-   ##
==========================================
- Coverage   90.74%   90.53%   -0.22%     
==========================================
  Files           1        1              
  Lines         508      507       -1     
==========================================
- Hits          461      459       -2     
- Misses         47       48       +1
Impacted Files Coverage Δ
pick.c 90.53% <75%> (-0.22%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f553d4a...fe86c66. Read the comment docs.

@ghost
Copy link

ghost commented Dec 30, 2017

OK, but by pressing another "special key" (Home or End) directly after typing the query fast, the screen remains blank here ... IMHO should dofilter only be reseted if filter_choices returns success ...

The reason for

case CTRL_A:
        cursor_position = 0;
        if (!dofilter)
                dochoices = 0;
        break;

in 59ddc0f is to avoid a blank screen (with no choices) for Ctrl-A, Ctrl-E, Left and Right ...

@mptre
Copy link
Owner Author

mptre commented Dec 30, 2017

Ah, good catch. Just updated #270 with a potential fix. I this works,
the dochoices logic could be simplified since dochoices = 1 should
only be implied if filter_choices() returns 1. Does that make sense?

@ghost
Copy link

ghost commented Dec 30, 2017

Great! Works perfect! Closing #268 in favor for this ...

@ghost ghost mentioned this pull request Dec 30, 2017
Typing a query fast enough to trigger the poll check in filter_choices()
could yield a wrong set of choices. Since filter_choices() is
interrupted, all choices have yet not been examined and potential
matches could still be left unexamined. Calling print_choices() in this
state causes the unexamined choices to never be reconsidered as
potential matches since they will have a score = 0. The solution is to
never call print_choices() if filter_choices() was interrupted.

Problem reported and partial solution provided by Jenz Guenther in
GitHub issue #268.
Enabling dofilter implies dochoices by now. Therefore, there's no longer
necessary to fiddle with dochoices for each key binding that doesn't
result in filtering of the choices.
@mptre
Copy link
Owner Author

mptre commented Dec 30, 2017

Nice! Please try the latest commit which includes a simplification of
the dochoices logic.

@ghost
Copy link

ghost commented Dec 30, 2017

That's it! Time for version 2.0.1 of pick! :-)

@mptre
Copy link
Owner Author

mptre commented Dec 30, 2017

Yes! I'm planning on releasing 2.0.1 next year (that's two days from now :trollface:)

@mptre mptre merged commit fe86c66 into master Dec 30, 2017
@mptre mptre deleted the fast-input branch December 30, 2017 19:09
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