diff options
-rw-r--r-- | src/nvim/api/buffer.c | 3 | ||||
-rw-r--r-- | src/nvim/lua/vim.lua | 2 | ||||
-rw-r--r-- | src/nvim/ops.c | 14 | ||||
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 12 | ||||
-rw-r--r-- | test/functional/api/buffer_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 14 |
7 files changed, 59 insertions, 13 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 67f4f92bf6..e2c0ebe5e0 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -722,7 +722,8 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, kExtmarkUndo); - changed_lines((linenr_T)start_row, 0, (linenr_T)end_row, (long)extra, true); + changed_lines((linenr_T)start_row, 0, (linenr_T)end_row + 1, + (long)extra, true); // adjust cursor like an extmark ( i e it was inside last_part_len) if (curwin->w_cursor.lnum == end_row && curwin->w_cursor.col > end_col) { diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index 00a4fe26d3..e13b9745a8 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -500,7 +500,7 @@ function vim.notify(msg, log_level, _opts) if log_level == vim.log.levels.ERROR then vim.api.nvim_err_writeln(msg) else - vim.api.nvim_echo(msg) + vim.api.nvim_echo({{msg}}, true, {}) end end diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 87d092281a..ea52d6a3d3 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3422,15 +3422,11 @@ error: if (dir == FORWARD) curbuf->b_op_start.lnum++; } - // Skip mark_adjust when adding lines after the last one, there - // can't be marks there. - if (curbuf->b_op_start.lnum + (y_type == kMTCharWise) - 1 + nr_lines - < curbuf->b_ml.ml_line_count) { - ExtmarkOp kind = (y_type == kMTLineWise && !(flags & PUT_LINE_SPLIT)) - ? kExtmarkUndo : kExtmarkNOOP; - mark_adjust(curbuf->b_op_start.lnum + (y_type == kMTCharWise), - (linenr_T)MAXLNUM, nr_lines, 0L, kind); - } + + ExtmarkOp kind = (y_type == kMTLineWise && !(flags & PUT_LINE_SPLIT)) + ? kExtmarkUndo : kExtmarkNOOP; + mark_adjust(curbuf->b_op_start.lnum + (y_type == kMTCharWise), + (linenr_T)MAXLNUM, nr_lines, 0L, kind); // note changed text for displaying and folding if (y_type == kMTCharWise) { diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 917a5e8eca..f0c1a1c7f9 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -930,10 +930,20 @@ func Test_Executable() " get "cat" path and remove the leading / let catcmd = exepath('cat')[1:] new + " check that the relative path works in / lcd / call assert_equal(1, executable(catcmd)) - call assert_equal('/' .. catcmd, exepath(catcmd)) + " let result = catcmd->exepath() + let result = exepath(catcmd) + " when using chroot looking for sbin/cat can return bin/cat, that is OK + if catcmd =~ '\<sbin\>' && result =~ '\<bin\>' + call assert_equal('/' .. substitute(catcmd, '\<sbin\>', 'bin', ''), result) + else + call assert_equal('/' .. catcmd, result) + endif bwipe + else + throw 'Skipped: does not work on this platform' endif endfunc diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index fb8ed6a9d7..81fad206da 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -513,6 +513,28 @@ describe('api/buf', function() eq({0, 8}, curbufmeths.get_extmark_by_id(ns, id2, {})) eq({0, 8}, curbufmeths.get_extmark_by_id(ns, id3, {})) end) + + it("correctly marks changed region for redraw #13890", function() + local screen = Screen.new(20, 5) + screen:attach() + + insert([[ + AAA + BBB + ]]) + + curbufmeths.set_text(0, 0, 1, 3, {'XXX', 'YYY'}) + + screen:expect([[ + XXX | + YYY | + ^ | + ~ | + | + + ]]) + + end) end) describe('nvim_buf_get_offset', function() diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 85baff412b..437a1858f3 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -476,6 +476,10 @@ describe('API', function() end) describe('nvim_notify', function() + it('can notify a info message', function() + nvim("notify", "hello world", 2, {}) + end) + it('can be overriden', function() command("lua vim.notify = function(...) return 42 end") eq(42, meths.exec_lua("return vim.notify('Hello world')", {})) @@ -483,7 +487,6 @@ describe('API', function() end) end) - describe('nvim_input', function() it("VimL error: does NOT fail, updates v:errmsg", function() local status, _ = pcall(nvim, "input", ":call bogus_fn()<CR>") diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 6087f9e7d6..6c2615eebd 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -507,6 +507,20 @@ describe('lua: nvim_buf_attach on_bytes', function() end) + it("linewise paste", function() + local check_events = setup_eventcheck(verify, origlines) + + feed'yyp' + check_events { + { "test1", "bytes", 1, 3, 1, 0, 16, 0, 0, 0, 1, 0, 16 }; + } + + feed'Gyyp' + check_events { + { "test1", "bytes", 1, 4, 8, 0, 130, 0, 0, 0, 1, 0, 18 }; + } + end) + it('inccomand=nosplit and substitute', function() if verify then pending("Verification can't be done when previewing") end |