Fixes: #19328 ?
When 'autocomplete' first fires, compl_leader is NULL because ins_compl_start() has not set it yet. This caused the prefix filter in ins_compl_build_pum(), find_next_completion_match() and find_common_prefix() to be bypassed, allowing non-prefix fuzzy omnifunc matches to appear in the PUM and be preinserted.
Extend get_leader_for_startcol() to fall back to compl_orig_text when compl_leader.string is NULL: if the match's cpt source startcol is less than compl_col the match includes pre-compl_col text, so return &compl_leader (NULL string) to signal "pass through"; otherwise return &compl_orig_text so callers filter by the original text. The compl_col <= 0 guard is kept only for the prepend-text path to avoid it interfering with the NULL-leader fallback when compl_col is zero.
With this change all callers of get_leader_for_startcol() automatically receive the correct filter string without additional helpers.
Also update Test_autocomplete_trigger Test 9 to reflect the new behavior: 'faberge' is no longer shown when completing 'foo' because it does not start with the current prefix.
Add Test_autocomplete_preinsert_null_leader() to verify that only prefix-matching candidates appear in the PUM and are preinserted.
https://github.com/vim/vim/pull/19447
(2 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@girishji Please review this.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@girishji approved this pull request.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks, reviewed.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
thanks both! 🙏
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()