-
-
Notifications
You must be signed in to change notification settings - Fork 338
Stop relying on ivy-completion-common-length #3065
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* ivy.el (ivy-completion-in-region): Return nil/t on no/sole match as well, not just in the multi-match case. Tiny local variable renaming and simplifications. Add FIXME for initial-input woes.
When completing ~/foo and ~/foobar is the only completion, vanilla completion inserts a trailing space on exit to indicate an exact match, even though completion-try-completion returned a cons. This is determined by completion--done which calls try-completion on the completion-try-completion return value i.s.o. the completion-all-completions candidate that was inserted. * ivy.el (ivy-completion-in-region-action): Prefer passing completion-try-completion 'new string' to completion--done when possible.
* ivy-test.el (ivy-completion-common-length): Extend tests.
Thanks to Kien Nguyen <[email protected]> and Madhu <[email protected]> for suggestions. Fixes parts of #1361, #1755, #2879, #3051, #3056, and https://bugs.gnu.org/76440. Relates to https://bugs.gnu.org/71419. * ivy.el (ivy--face-list-p): New compatibility shim. (ivy-completion-common-length): Use it to handle both atom and list values for the face property, since it varies across Emacs versions. Use previous-single-property-change instead of iterating by char. Improve documentation. (ivy-completion-in-region): Translate a 'not found' result of ivy-completion-common-length into a first difference at index 0, not at the end of the string. That means, interpret a lack of completions-first-difference as no commonality. This is more consistent with both the definition of ivy-completion-common-length and completion changes in Emacs 30. * ivy-test.el (ivy-completion-common-length): Extend tests.
009b941 to
d5e3974
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This was referenced Feb 24, 2025
This was referenced Feb 24, 2025
Closed
1a4d59f to
6554d05
Compare
The latter is very problematic: it is specific to a single candidate, does not necessarily correspond to the string being completed, complicates bounds calculations, relies on only partially documented presentation details rather than the usual API, etc. When completion-all-completions returns a base-size (which in practice seems to be most if not all the time), it corresponds more closely to the substring that is being completed and will be replaced. This should address most of the remaining issues in reports #1361, #1755, #2643, #2879, #3051, #3056, and https://bugs.gnu.org/76440. * ivy.el (ivy-completion-common-length): Discourage use. (ivy-completion-in-region): When completion-all-completions returns a base-size, prefer that over the completions-first-difference face to determine the completion boundaries and initial-input. Fixes #1755. Fixes #2643. Fixes #2879. Closes #3051. Fixes #3056.
* ivy.el (ivy-completion-in-region): Determine no/sole match based on completion-try-completion result, not completion-all-completions. Heed completion-fail-discreetly and completion-show-inline-help and use minibuffer-message for consistency with vanilla completion. Move point to end and call exit-function on sole match. Fixes #2946.
a5ea765 to
5e93415
Compare
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Existing behavior is incorrect
compat
Issues relating to backward/forward compatibility
enhancement
Suggestion to improve or extend existing behavior
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses several shortcomings in the use of
ivy-completion-common-lengthbyivy-completion-in-region; see each commit individually for details.It takes a slightly more general approach than that in #3051.
Re: #1361, #1755, #2879, #3056, and https://bugs.gnu.org/76440.