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

Add tests for setting autocomplete delimiters & support no delimiters #16

Merged
merged 4 commits into from Nov 17, 2020

Conversation

neiljp
Copy link
Collaborator

@neiljp neiljp commented Nov 10, 2020

On exploring a fix for #13, I saw there was already a set_autocomplete_delims.

After an initial refactor of the common compl function into a factory fixture, this PR adds tests for the above method, initially with parametrization demonstrating how the problem observed in zulip-terminal can be resolved (or at least worked around), then expanding it to illustrate behavior when the autocomplete list contains phrases with word separators which are not a space - at this point simply expanding test coverage.

The last commit(s) extend the functionality and test cases to allow setting the autocomplete delimters to be an empty string, ie. no characters - this essentially allows any character in the autocomplete phrases, but matches all text from the start of the text box.

Note that I've left the the last two commits separate for now, but these can squashed before merging.
(currently this emphasizes that the existing code is broken when passed an empty string)

The tests now use the completion_func_for_source fixture, which is a
factory generating a function from the passed in source (previously
available from the scope outside the function)
With no autocomplete delimiters, all of the characters to the left of
the cursor are compared for a match. This is useful in situations where
it is not important for the completion to occur in the middle of the
text, and it is perhaps more important that delimiter characters are
allowed in the phrase(s) to autocomplete themselves.

One example case this helps is where the autocomplete phrase may contain a
space (eg. multi-part personal names); if the delimiter set also
includes a space then all name-parts before the space may be neglected
in the match. This is particularly apparent when backspacing and
autocompleting multiple times.

Tests added
@neiljp neiljp force-pushed the 2020-11-08-autocomplete-delimiters branch from f538573 to 2db418b Compare November 10, 2020 18:16
@neiljp
Copy link
Collaborator Author

neiljp commented Nov 10, 2020

@rr- I squashed the last two commits and updated that commit text. If you've happy with that then based on your approval this should be good to merge.

@rr- rr- merged commit 006f19d into rr-:master Nov 17, 2020
@rr-
Copy link
Owner

rr- commented Nov 17, 2020

Thanks @neiljp do you need to get this version released on PyPI or are you planning any further PRs?

@neiljp
Copy link
Collaborator Author

neiljp commented Nov 17, 2020

@rr- I don't have any further PRs planned right now, so I'd be happy with having a new release of this 👍

@rr-
Copy link
Owner

rr- commented Nov 20, 2020 via email

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.

None yet

2 participants