[vim/vim] Fix: 'preinsert' inserting wrong word with smartcase (autocomplete only) (PR #18313)

19 views
Skip to first unread message

girish

unread,
Sep 16, 2025, 3:45:09 AM (6 days ago) Sep 16
to vim/vim, Subscribed

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18313

Commit Summary

  • 03758f3 Fix: 'preinsert' inserting wrong word with smartcase (autocomplete only)

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313@github.com>

Shane-XB-Qian

unread,
Sep 16, 2025, 9:12:00 AM (6 days ago) Sep 16
to vim/vim, Subscribed
Shane-XB-Qian left a comment (vim/vim#18313)
you had done much special or specific customization to preinsert/wildtrigger/autocomplete, the difference between generic with those seems became more and more, if this was acceptable, perhaps you'd better doc it somewhere, for the people who's like the generic way and generic way been continue to be maintained by (if) someone else later.

--
shane.xb.qian


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/c3298706348@github.com>

Christian Brabandt

unread,
Sep 16, 2025, 3:29:43 PM (6 days ago) Sep 16
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/insexpand.c:

> @@ -5863,8 +5863,12 @@ find_common_prefix(size_t *prefix_len, int curbuf_only)
 	    {
 		if (first == NULL)
 		{
-		    first = compl->cp_str.string;
-		    len = (int)STRLEN(first);
+		    if (STRNCMP(ins_compl_leader(), compl->cp_str.string,
+				ins_compl_leader_len()) == 0)

can you move this if condition into the if condition above?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/review/3231394742@github.com>

girish

unread,
Sep 17, 2025, 6:43:53 AM (5 days ago) Sep 17
to vim/vim, Subscribed

@girishji commented on this pull request.


In src/insexpand.c:

> @@ -5863,8 +5863,12 @@ find_common_prefix(size_t *prefix_len, int curbuf_only)
 	    {
 		if (first == NULL)
 		{
-		    first = compl->cp_str.string;
-		    len = (int)STRLEN(first);
+		    if (STRNCMP(ins_compl_leader(), compl->cp_str.string,
+				ins_compl_leader_len()) == 0)

Thanks, done.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/review/3233812567@github.com>

girish

unread,
Sep 17, 2025, 6:44:09 AM (5 days ago) Sep 17
to vim/vim, Push

@girishji pushed 2 commits.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/before/b1f37b905ac9385c3aacefe53cb5c63b39c25c62/after/cbacd5b5638c6fb237098c1b8b57e9b716a2ab19@github.com>

girish

unread,
Sep 17, 2025, 9:11:04 AM (5 days ago) Sep 17
to vim/vim, Push

@girishji pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/before/cbacd5b5638c6fb237098c1b8b57e9b716a2ab19/after/6209491f3ed9be9f466144a936c0b300546e615e@github.com>

Christian Brabandt

unread,
Sep 17, 2025, 3:58:36 PM (5 days ago) Sep 17
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18313)

thanks


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/c3304386685@github.com>

Christian Brabandt

unread,
Sep 17, 2025, 4:02:59 PM (5 days ago) Sep 17
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/insexpand.c:

> @@ -5861,7 +5861,8 @@ find_common_prefix(size_t *prefix_len, int curbuf_only)
 	    if (!match_limit_exceeded && (!curbuf_only
 			|| cpt_sources_array[cur_source].cs_flag == '.'))
 	    {
-		if (first == NULL)
+		if (first == NULL && STRNCMP(ins_compl_leader(),
+			    compl->cp_str.string, ins_compl_leader_len()) == 0)

is this now correct? Don't we need to also change the else below to else if (first != NULL)? Or should we also run into the else case when the strcmp() fails?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/review/3236088086@github.com>

girish

unread,
Sep 18, 2025, 9:19:05 AM (4 days ago) Sep 18
to vim/vim, Push

@girishji pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/before/6209491f3ed9be9f466144a936c0b300546e615e/after/6a3e203e3a060605bb03c94592f0bf1b2a6969af@github.com>

girish

unread,
Sep 18, 2025, 9:19:40 AM (4 days ago) Sep 18
to vim/vim, Subscribed

@girishji commented on this pull request.


In src/insexpand.c:

> @@ -5861,7 +5861,8 @@ find_common_prefix(size_t *prefix_len, int curbuf_only)
 	    if (!match_limit_exceeded && (!curbuf_only
 			|| cpt_sources_array[cur_source].cs_flag == '.'))
 	    {
-		if (first == NULL)
+		if (first == NULL && STRNCMP(ins_compl_leader(),
+			    compl->cp_str.string, ins_compl_leader_len()) == 0)

yes it needs a check.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/review/3239685413@github.com>

Christian Brabandt

unread,
Sep 18, 2025, 3:37:10 PM (4 days ago) Sep 18
to vim/vim, Subscribed

Closed #18313 via a8f7957.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/issue_event/19784033173@github.com>

Christian Brabandt

unread,
Sep 18, 2025, 3:37:15 PM (4 days ago) Sep 18
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18313)

thanks


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/c3309337939@github.com>

girish

unread,
Sep 18, 2025, 4:22:55 PM (4 days ago) Sep 18
to vim/vim, Subscribed
girishji left a comment (vim/vim#18313)

Thanks.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18313/c3309562605@github.com>

Reply all
Reply to author
Forward
0 new messages