aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorSpencer Baugh2023-09-05 15:40:06 -0400
committerStefan Monnier2023-09-05 17:16:57 -0400
commit03ac16ece40ba3e3ba805d6a61cc457d84bf3792 (patch)
treefa0bf6049b715bcb638fd2d6187736f66c956d31 /java
parentc586d984f279aa61de4f5dfc4f6df660188dd0f6 (diff)
downloademacs-03ac16ece40ba3e3ba805d6a61cc457d84bf3792.tar.gz
emacs-03ac16ece40ba3e3ba805d6a61cc457d84bf3792.zip
Correctly handle common prefixes in substring completion
Substring completion would previously not complete the longest common substring if that substring was a prefix of all the completion alternatives. Now it does. An explanation of this bug Substring completion is implemented by passing the `prefix' symbol as part of the pattern passed to completion-pcm--merge-completions. This symbol is supposed to cause completion-pcm--merge-completions to "grow" a completion of a common substring only from the "right" of the symbol (a common suffix), not from the "left" of the symbol (a common prefix). Yes, this is the opposite of what the name `prefix' would imply. When processing a symbolic element of the pattern, completion-pcm--merge-completions first finds the common prefix of all the completions in that part of the pattern (using try-completion). Then for `prefix' and other elements which want to complete a common suffix, the common prefix is removed from each element and then the common suffix is calculated with completion--common-suffix. If the common prefix covers the entirety of all the alternatives (i.e. when "unique" is true in the code), it's also a common suffix. In that case, the common suffix calculation (if it runs) is basically a no-op which will produce an empty string, since we removed the common prefix before running it. Before this change, `prefix' elements would unconditionally discard the common prefix, which produced the wrong result in the case that common prefix == common suffix. For example: (completion-pcm--merge-completions '("ab" "ab") '(prefix "b")) -> ("b") Now we detect this situation and include the common prefix in this case for `prefix' elements. Then we get: (completion-pcm--merge-completions '("ab" "ab") '(prefix "b")) -> ("b" "a") which is correct. * lisp/minibuffer.el (completion-pcm--merge-completions): Don't ignore a common suffix in a `prefix' pattern element when it's also a common prefix. * test/lisp/minibuffer-tests.el (completion-substring-test-5): Add a test.
Diffstat (limited to 'java')
0 files changed, 0 insertions, 0 deletions