patch 9.1.1612: Ctrl-G/Ctrl-T do not ignore the end search delimiter

Commit: 
https://github.com/vim/vim/commit/c03990d30f742154d93184383cae713b69f1147c
Author: Christian Brabandt <c...@256bit.org>
Date:   Sat Aug 9 23:47:01 2025 +0200

    patch 9.1.1612: Ctrl-G/Ctrl-T do not ignore the end search delimiter
    
    Problem:  Ctrl-G/Ctrl-T does not ignore the end search delimiter
              (irisjae)
    Solution: Check if the pattern ends with a search delimiter and ignore
              it, unless it is part of the pattern.
    
    fixes: #17895
    closes: #17933
    
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/ex_getln.c b/src/ex_getln.c
index 0febe432b..93ce07062 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -620,6 +620,7 @@ may_adjust_incsearch_highlighting(
     int            search_flags = SEARCH_NOOF;
     int            i;
     int            save;
+    int            bslsh = FALSE;
     int            search_delim;
 
     // Parsing range may already set the last search pattern.
@@ -652,6 +653,18 @@ may_adjust_incsearch_highlighting(
     else
        pat = ccline.cmdbuff + skiplen;
 
+    // do not search for the search end delimiter,
+    // unless it is part of the pattern
+    if (patlen > 2 && firstc == pat[patlen - 1])
+    {
+       patlen--;
+       if (pat[patlen - 1] == '\')
+       {
+           pat[patlen - 1] = firstc;
+           bslsh = TRUE;
+       }
+    }
+
     cursor_off();
     out_flush();
     if (c == Ctrl_G)
@@ -675,6 +688,8 @@ may_adjust_incsearch_highlighting(
                 pat, patlen, count, search_flags, RE_SEARCH, NULL);
     --emsg_off;
     pat[patlen] = save;
+    if (bslsh)
+       pat[patlen - 1] = '\';
     if (i)
     {
        is_state->search_start = is_state->match_start;
diff --git a/src/testdir/dumps/Test_incsearch_delim_01.dump 
b/src/testdir/dumps/Test_incsearch_delim_01.dump
new file mode 100644
index 000000000..84a5d7c75
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_delim_01.dump
@@ -0,0 +1,6 @@
+|1+0&#ffffff0| |v+0&#ffff4012|i|m| |i+0&#ffffff0|n|c| @65
+|2| |v+1&&|i|m| |/+0&&| @67
+|3| |v+0&#ffff4012|i|m| |/+0&#ffffff0| @67
+|4| |v+0&#ffff4012|i|m| |?+0&#ffffff0| @67
+|5| |v+0&#ffff4012|i|m| |?+0&#ffffff0| @67
+|/|v|i|m| |/> @68
diff --git a/src/testdir/dumps/Test_incsearch_delim_02.dump 
b/src/testdir/dumps/Test_incsearch_delim_02.dump
new file mode 100644
index 000000000..46b22e0cb
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_delim_02.dump
@@ -0,0 +1,6 @@
+|1+0&#ffffff0| |v+0&#ffff4012|i|m| |i+0&#ffffff0|n|c| @65
+|2| |v+0&#ffff4012|i|m| |/+0&#ffffff0| @67
+|3| |v+1&&|i|m| |/+0&&| @67
+|4| |v+0&#ffff4012|i|m| |?+0&#ffffff0| @67
+|5| |v+0&#ffff4012|i|m| |?+0&#ffffff0| @67
+|?|v|i|m| |?> @68
diff --git a/src/testdir/dumps/Test_incsearch_delim_03.dump 
b/src/testdir/dumps/Test_incsearch_delim_03.dump
new file mode 100644
index 000000000..2aca1c8e8
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_delim_03.dump
@@ -0,0 +1,6 @@
+|1+0&#ffffff0| |v|i|m| |i|n|c| @65
+|2| |v+0&#ffff4012|i|m| |/| +0&#ffffff0@67
+|3| |v+1&&|i|m| |/| +0&&@67
+|4| |v|i|m| |?| @67
+|5| |v|i|m| |?| @67
+|/|v|i|m| |\|/> @67
diff --git a/src/testdir/dumps/Test_incsearch_delim_04.dump 
b/src/testdir/dumps/Test_incsearch_delim_04.dump
new file mode 100644
index 000000000..2d049a001
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_delim_04.dump
@@ -0,0 +1,6 @@
+|1+0&#ffffff0| |v|i|m| |i|n|c| @65
+|2| |v|i|m| |/| @67
+|3| |v|i|m| |/| @67
+|4| |v+0&#ffff4012|i|m| |?| +0&#ffffff0@67
+|5| |v+1&&|i|m| |?| +0&&@67
+|?|v|i|m| |\|?> @67
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 4e5fd0620..65b55999e 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -2254,5 +2254,86 @@ func Test_search_with_invalid_range()
   bwipe!
 endfunc
 
+func Test_incsearch_delimiter_ctrlg()
+  CheckOption incsearch
+  CheckScreendump
+  CheckRunVimInTerminal
+  call assert_equal(0, &scrolloff)
+  call writefile([
+       \ 'set incsearch hls',
+  \ 'call setline(1, ["1 vim inc", "2 vim /", "3 vim /", "4 vim ?", "5 vim 
?"])',
+       \ 'normal gg',
+       \ 'redraw',
+       \ ], 'Xscript_incsearch_delim', 'D')
+  let buf = RunVimInTerminal('-S Xscript_incsearch_delim', {'rows': 6})
+
+  call term_sendkeys(buf, '/')
+  sleep 100m
+  call term_sendkeys(buf, 'v')
+  sleep 100m
+  call term_sendkeys(buf, 'i')
+  sleep 100m
+  call term_sendkeys(buf, 'm')
+  sleep 100m
+  call term_sendkeys(buf, ' ')
+  sleep 100m
+  call term_sendkeys(buf, '/')
+  sleep 100m
+  call term_sendkeys(buf, "\<C-G>")
+  call VerifyScreenDump(buf, 'Test_incsearch_delim_01', {})
+  call term_sendkeys(buf, "\<Esc>")
+
+  call term_sendkeys(buf, ":5\<cr>")
+  call term_sendkeys(buf, '?')
+  sleep 100m
+  call term_sendkeys(buf, 'v')
+  sleep 100m
+  call term_sendkeys(buf, 'i')
+  sleep 100m
+  call term_sendkeys(buf, 'm')
+  sleep 100m
+  call term_sendkeys(buf, ' ')
+  sleep 100m
+  call term_sendkeys(buf, '?')
+  sleep 100m
+  call term_sendkeys(buf, "\<C-T>")
+  call VerifyScreenDump(buf, 'Test_incsearch_delim_02', {})
+  call term_sendkeys(buf, "\<Esc>")
+
+  call term_sendkeys(buf, '/')
+  sleep 100m
+  call term_sendkeys(buf, 'v')
+  sleep 100m
+  call term_sendkeys(buf, 'i')
+  sleep 100m
+  call term_sendkeys(buf, 'm')
+  sleep 100m
+  call term_sendkeys(buf, ' ')
+  sleep 100m
+  call term_sendkeys(buf, '\/')
+  sleep 100m
+  call term_sendkeys(buf, "\<C-G>")
+  call VerifyScreenDump(buf, 'Test_incsearch_delim_03', {})
+  call term_sendkeys(buf, "\<Esc>")
+
+  call term_sendkeys(buf, ":5\<cr>")
+  call term_sendkeys(buf, '?')
+  sleep 100m
+  call term_sendkeys(buf, 'v')
+  sleep 100m
+  call term_sendkeys(buf, 'i')
+  sleep 100m
+  call term_sendkeys(buf, 'm')
+  sleep 100m
+  call term_sendkeys(buf, ' ')
+  sleep 100m
+  call term_sendkeys(buf, '\?')
+  sleep 100m
+  call term_sendkeys(buf, "\<C-T>")
+  call VerifyScreenDump(buf, 'Test_incsearch_delim_04', {})
+  call term_sendkeys(buf, "\<Esc>")
+
+  call StopVimInTerminal(buf)
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 4716c5d0d..68f1ff294 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1612,
 /**/
     1611,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1ukrbk-005CX6-QW%40256bit.org.

Raspunde prin e-mail lui