]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1750: completion: preinserted text highlighed using ComplMatchIns v9.1.1750
authorGirish Palya <girishji@gmail.com>
Wed, 10 Sep 2025 08:04:24 +0000 (04:04 -0400)
committerChristian Brabandt <cb@256bit.org>
Wed, 10 Sep 2025 08:04:24 +0000 (04:04 -0400)
Problem:  completion: preinserted text highlighed using ComplMatchIns
Solution: Use highlighting group PreInsert and update the documentation
          (Girish Palya).

When "preinsert" is included in 'completeopt', only the PreInsert
highlight group should be applied, whether autocompletion is active or not.
Previously, ComplMatchIns was used when autocompletion was not enabled.

Related to https://github.com/vim/vim/pull/18213.

closes: #18254

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/options.txt
runtime/doc/syntax.txt
src/insexpand.c
src/testdir/dumps/Test_autocompletedelay_7.dump
src/version.c

index 51c3c64e5967c2a382bb14cb7ede4a57e4d0a768..54b046b7d2f756686006ea74a16574afdfd4b293 100644 (file)
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.1.  Last change: 2025 Sep 08
+*options.txt*  For Vim version 9.1.  Last change: 2025 Sep 10
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -2303,13 +2303,13 @@ A jump table for the options with a short description can be found at |Q_op|.
           preinsert
                    When autocompletion is not enabled, inserts the part of the
                    first candidate word beyond the current completion leader,
-                   highlighted with |hl-ComplMatchIns|.  The cursor does not
+                   highlighted with |hl-PreInsert|.  The cursor does not
                    move.  Requires 'fuzzy' unset and 'menuone' in 'completeopt'.
 
                    When 'autocomplete' is enabled, inserts the longest common
-                   prefix of matches (from all shown items or buffer-specific
-                   matches), highlighted with |hl-PreInsert|.  This occurs only
-                   when no menu item is selected.  Press CTRL-Y to accept.
+                   prefix of matches (from all shown items or from the
+                   current buffer items).  This occurs only when no menu item
+                   is selected.  Press CTRL-Y to accept.
 
           preview  Show extra information about the currently selected
                    completion in the preview window.  Only works in
@@ -4725,7 +4725,7 @@ A jump table for the options with a short description can be found at |Q_op|.
        |hl-PmenuThumb|  X  popup menu scrollbar thumb
        |hl-PmenuMatch|  k  popup menu matched text
        |hl-PmenuMatchSel| <  popup menu matched text in selected line
-       |hl-PreInsert|   I  text inserted when "preinsert" and 'autocomplete'
+       |hl-PreInsert|   I  text inserted when "preinsert" is in 'completeopt'
 
        The display modes are:
                r       reverse         (termcap entry "mr" and "me")
index 949bf1759fa7cc480ac06d8b841d35af694f51f9..39a64da63d82aed341714b686bfb7c257e3618bc 100644 (file)
@@ -1,4 +1,4 @@
-*syntax.txt*   For Vim version 9.1.  Last change: 2025 Sep 08
+*syntax.txt*   For Vim version 9.1.  Last change: 2025 Sep 10
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -5999,7 +5999,7 @@ PmenuMatchSel     Popup menu: Matched text in selected item. Applied in
                                                        *hl-ComplMatchIns*
 ComplMatchIns  Matched text of the currently inserted completion.
                                                        *hl-PreInsert*
-PreInsert      Text inserted during autocompletion when "preinsert".
+PreInsert      Text inserted when "preinsert" is in 'completeopt'.
                                                        *hl-PopupSelected*
 PopupSelected  Popup window created with |popup_menu()|.  Linked to
                |hl-PmenuSel| by default.
index d797bc5d940012ee29c2f81cb5dbf35d33059afd..dac3698cf797fc107b4b108657aadbfbccd61882 100644 (file)
@@ -1067,10 +1067,13 @@ ins_compl_col_range_attr(linenr_T lnum, int col)
 {
     int            start_col;
     int            attr;
+    int            has_preinsert = ins_compl_has_preinsert();
 
     if ((get_cot_flags() & COT_FUZZY)
-           || (!compl_autocomplete
+           || (!has_preinsert
                && (attr = syn_name2attr((char_u *)"ComplMatchIns")) == 0)
+           || (!compl_autocomplete && has_preinsert
+               && (attr = syn_name2attr((char_u *)"PreInsert")) == 0)
            || (compl_autocomplete
                && (!compl_autocomplete_preinsert
                    || (attr = syn_name2attr((char_u *)"PreInsert")) == 0)))
@@ -2531,9 +2534,7 @@ ins_compl_new_leader(void)
        if (compl_started && compl_autocomplete
                && !ins_compl_preinsert_effect())
        {
-           if (ins_compl_insert(TRUE, TRUE) != OK)
-               (void)ins_compl_insert(FALSE, FALSE);
-           else
+           if (ins_compl_insert(TRUE, TRUE) == OK)
                compl_autocomplete_preinsert = TRUE;
        }
        else
index 954b785d87cacd333dc91f67f50469216fb92a2b..6c43fa46e922ed23a036e828837c021c4f4975d4 100644 (file)
@@ -1,7 +1,7 @@
 |f+0&#ffffff0|o@1| @71
 |f|o@1|b|a|r| @68
 |f|o@1|b|a|r|b|a|z| @65
-|f>o@1| @71
+|f>o+0#00e0003&@1| +0#0000000&@71
 |f+0#0000001#e0e0e08|o@1| @11| +0#4040ff13#ffffff0@59
 |f+0#0000001#ffd7ff255|o@1|b|a|r| @8| +0#4040ff13#ffffff0@59
 |f+0#0000001#ffd7ff255|o@1|b|a|r|b|a|z| @5| +0#4040ff13#ffffff0@59
index 10958a5091e0decc0b0e5546468d854df77c731e..c741108d9084a8cf6cf0b9279665345f569c6297 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1750,
 /**/
     1749,
 /**/