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 <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-08-09 23:47:01 +02:00
parent c43a0614d4
commit c03990d30f
7 changed files with 122 additions and 0 deletions

View File

@ -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;