summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-06 12:49:29 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-06 12:49:29 +0200
commitdb294adc65d73ffa5cdf3d0ab45ccbf05b965414 (patch)
treeb10feaaa11f172b219b2479623dfd62b571d633a
parent9aeb33639f49511cc16962a11a40844693ddb15e (diff)
downloadvim-git-db294adc65d73ffa5cdf3d0ab45ccbf05b965414.tar.gz
patch 8.1.1475: search string not displayed when 'rightleft' is setv8.1.1475
Problem: Search string not displayed when 'rightleft' is set. Solution: Clear the right part of the old text. (closes #4488, closes #4489)
-rw-r--r--src/search.c9
-rw-r--r--src/testdir/test_search.vim22
-rw-r--r--src/version.c2
3 files changed, 31 insertions, 2 deletions
diff --git a/src/search.c b/src/search.c
index 423f3fccb..ce87a3ef3 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1462,6 +1462,7 @@ do_search(
if (curwin->w_p_rl && *curwin->w_p_rlc == 's')
{
char_u *r;
+ size_t pat_len;
r = reverse_text(msgbuf);
if (r != NULL)
@@ -1471,9 +1472,13 @@ do_search(
// move reversed text to beginning of buffer
while (*r != NUL && *r == ' ')
r++;
- mch_memmove(msgbuf, r, msgbuf + STRLEN(msgbuf) - r);
+ pat_len = msgbuf + STRLEN(msgbuf) - r;
+ mch_memmove(msgbuf, r, pat_len);
// overwrite old text
- vim_memset(r, ' ', msgbuf + STRLEN(msgbuf) - r);
+ if ((size_t)(r - msgbuf) >= pat_len)
+ vim_memset(r, ' ', pat_len);
+ else
+ vim_memset(msgbuf + pat_len, ' ', r - msgbuf);
}
}
#endif
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index d59f39dc7..8090deeeb 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -1289,3 +1289,25 @@ func Test_search_match_at_curpos()
close!
endfunc
+
+func Test_search_display_pattern()
+ new
+ call setline(1, ['foo', 'bar', 'foobar'])
+
+ call cursor(1, 1)
+ let @/ = 'foo'
+ let pat = escape(@/, '()*?'. '\s\+')
+ let g:a = execute(':unsilent :norm! n')
+ call assert_match(pat, g:a)
+
+ " right-left
+ if exists("+rightleft")
+ set rl
+ call cursor(1, 1)
+ let @/ = 'foo'
+ let pat = 'oof/\s\+'
+ let g:a = execute(':unsilent :norm! n')
+ call assert_match(pat, g:a)
+ set norl
+ endif
+endfunc
diff --git a/src/version.c b/src/version.c
index a422cb0a4..8f707b026 100644
--- a/src/version.c
+++ b/src/version.c
@@ -768,6 +768,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1475,
+/**/
1474,
/**/
1473,