aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ex_cmds.c5
-rw-r--r--src/nvim/ops.c1
-rw-r--r--src/nvim/quickfix.c4
-rw-r--r--src/nvim/syntax.c12
-rw-r--r--src/nvim/testdir/test_substitute.vim10
-rw-r--r--src/nvim/testdir/test_virtualedit.vim9
6 files changed, 32 insertions, 9 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 2e8bd79c81..04aa8f7ef6 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3524,6 +3524,11 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
// Note: If not first match on a line, column can't be known here
current_match.start.lnum = sub_firstlnum;
+ // Match might be after the last line for "\n\zs" matching at
+ // the end of the last line.
+ if (lnum > curbuf->b_ml.ml_line_count) {
+ break;
+ }
if (sub_firstline == NULL) {
sub_firstline = vim_strsave(ml_get(sub_firstlnum));
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 030782cbcc..fbbdfdcd82 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1562,6 +1562,7 @@ int op_delete(oparg_T *oap)
oap->end = curwin->w_cursor;
curwin->w_cursor = oap->start;
}
+ mb_adjust_opend(oap);
}
if (oap->line_count == 1) { /* delete characters within one line */
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 4ca9ca2a3e..a9e0c22a76 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1693,9 +1693,7 @@ static int copy_loclist(const qf_list_T *from_qfl,
}
if (from_qfl->qf_ctx != NULL) {
to_qfl->qf_ctx = xcalloc(1, sizeof(*to_qfl->qf_ctx));
- if (to_qfl->qf_ctx != NULL) {
- tv_copy(from_qfl->qf_ctx, to_qfl->qf_ctx);
- }
+ tv_copy(from_qfl->qf_ctx, to_qfl->qf_ctx);
} else {
to_qfl->qf_ctx = NULL;
}
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index ac8ace9fff..bdbc09a87a 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -2460,11 +2460,8 @@ update_si_end(
int force /* when TRUE overrule a previous end */
)
{
- lpos_T startpos;
- lpos_T endpos;
lpos_T hl_endpos;
lpos_T end_endpos;
- int end_idx;
/* return quickly for a keyword */
if (sip->si_idx < 0)
@@ -2480,9 +2477,12 @@ update_si_end(
* We need to find the end of the region. It may continue in the next
* line.
*/
- end_idx = 0;
- startpos.lnum = current_lnum;
- startpos.col = startcol;
+ int end_idx = 0;
+ lpos_T startpos = {
+ .lnum = current_lnum,
+ .col = startcol,
+ };
+ lpos_T endpos = { 0 };
find_endpos(sip->si_idx, &startpos, &endpos, &hl_endpos,
&(sip->si_flags), &end_endpos, &end_idx, sip->si_extmatch);
diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim
index b29b678129..e209310a05 100644
--- a/src/nvim/testdir/test_substitute.vim
+++ b/src/nvim/testdir/test_substitute.vim
@@ -149,6 +149,7 @@ func Run_SubCmd_Tests(tests)
for t in a:tests
let start = line('.') + 1
let end = start + len(t[2]) - 1
+ " TODO: why is there a one second delay the first time we get here?
exe "normal o" . t[0]
call cursor(start, 1)
exe t[1]
@@ -717,3 +718,12 @@ one two
close!
endfunc
+
+func Test_sub_beyond_end()
+ new
+ call setline(1, '#')
+ let @/ = '^#\n\zs'
+ s///e
+ call assert_equal('#', getline(1))
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_virtualedit.vim b/src/nvim/testdir/test_virtualedit.vim
index 67adede8d7..1e6b26a057 100644
--- a/src/nvim/testdir/test_virtualedit.vim
+++ b/src/nvim/testdir/test_virtualedit.vim
@@ -73,3 +73,12 @@ func Test_edit_CTRL_G()
bwipe!
set virtualedit=
endfunc
+
+func Test_edit_change()
+ new
+ set virtualedit=all
+ call setline(1, "\t⒌")
+ normal Cx
+ call assert_equal('x', getline(1))
+ bwipe!
+endfunc