diff options
-rw-r--r-- | runtime/filetype.vim | 11 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 11 | ||||
-rw-r--r-- | src/nvim/extmark.c | 1 | ||||
-rw-r--r-- | src/nvim/ops.c | 8 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 1 | ||||
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 47 |
6 files changed, 68 insertions, 11 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 7bfe048bbf..724a96cb01 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -596,7 +596,7 @@ au BufNewFile,BufRead *.fan,*.fwt setf fan au BufNewFile,BufRead *.factor setf factor " Fennel -autocmd BufRead,BufNewFile *.fnl setf fennel +autocmd BufRead,BufNewFile *.fnl setf fennel " Fetchmail RC file au BufNewFile,BufRead .fetchmailrc setf fetchmail @@ -640,7 +640,7 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom " Gift (Moodle) -autocmd BufRead,BufNewFile *.gift setf gift +autocmd BufRead,BufNewFile *.gift setf gift " Git au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit @@ -711,7 +711,7 @@ au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc au BufNewFile,BufRead *.haml setf haml " Hamster Classic | Playground files -au BufNewFile,BufRead *.hsm setf hamster +au BufNewFile,BufRead *.hsm setf hamster " Haskell au BufNewFile,BufRead *.hs,*.hsc,*.hs-boot setf haskell @@ -1338,12 +1338,15 @@ au BufNewFile,BufRead *.pdb setf prolog " Promela au BufNewFile,BufRead *.pml setf promela +" Property Specification Language (PSL) +au BufNewFile,BufRead *.psl setf psl + " Google protocol buffers au BufNewFile,BufRead *.proto setf proto au BufNewFile,BufRead *.pbtxt setf pbtxt " Poke -au BufNewFile,BufRead *.pk setf poke +au BufNewFile,BufRead *.pk setf poke " Protocols au BufNewFile,BufRead */etc/protocols setf protocols diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b191e8cf67..3e330b88a2 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -968,12 +968,6 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) mark_adjust_nofold(last_line - num_lines + 1, last_line, -(last_line - dest - extra), 0L, kExtmarkNOOP); - // extmarks are handled separately - extmark_move_region(curbuf, line1-1, 0, start_byte, - line2-line1+1, 0, extent_byte, - dest+line_off, 0, dest_byte+byte_off, - kExtmarkUndo); - changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra, false); // send update regarding the new lines that were added @@ -995,6 +989,11 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) smsg(_("%" PRId64 " lines moved"), (int64_t)num_lines); } + extmark_move_region(curbuf, line1-1, 0, start_byte, + line2-line1+1, 0, extent_byte, + dest+line_off, 0, dest_byte+byte_off, + kExtmarkUndo); + /* * Leave the cursor on the last of the moved lines. */ diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index cacbeddb32..2906a2196b 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -702,6 +702,7 @@ void extmark_move_region( int new_row, colnr_T new_col, bcount_t new_byte, ExtmarkOp undo) { + curbuf->deleted_bytes2 = 0; // TODO(bfredl): this is not synced to the buffer state inside the callback. // But unless we make the undo implementation smarter, this is not ensured // anyway. diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 2cd71f2360..190ca2e93b 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1676,12 +1676,18 @@ int op_delete(oparg_T *oap) curbuf_splice_pending++; pos_T startpos = curwin->w_cursor; // start position for delete + bcount_t deleted_bytes = (bcount_t)STRLEN( + ml_get(startpos.lnum)) + 1 - startpos.col; truncate_line(true); // delete from cursor to end of line curpos = curwin->w_cursor; // remember curwin->w_cursor curwin->w_cursor.lnum++; + + for (linenr_T i = 1; i <= oap->line_count - 2; i++) { + deleted_bytes += (bcount_t)STRLEN( + ml_get(startpos.lnum + i)) + 1; + } del_lines(oap->line_count - 2, false); - bcount_t deleted_bytes = (bcount_t)curbuf->deleted_bytes2 - startpos.col; // delete from start of line until op_end n = (oap->end.col + 1 - !oap->inclusive); diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index bd2e673570..3cfc964f0a 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -376,6 +376,7 @@ let s:filename_checks = { \ 'ps1': ['file.ps1', 'file.psd1', 'file.psm1', 'file.pssc'], \ 'ps1xml': ['file.ps1xml'], \ 'psf': ['file.psf'], + \ 'psl': ['file.psl'], \ 'puppet': ['file.pp'], \ 'pyrex': ['file.pyx', 'file.pxd'], \ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', 'file.ptl', 'file.pyi', 'SConstruct'], diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 3cb14ca93f..5da8452a51 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -461,6 +461,36 @@ describe('lua: nvim_buf_attach on_bytes', function() } end) + it("deleting lines", function() + local check_events = setup_eventcheck(verify, origlines) + + feed("dd") + + check_events { + { "test1", "bytes", 1, 3, 0, 0, 0, 1, 0, 16, 0, 0, 0 }; + } + + feed("d2j") + + check_events { + { "test1", "bytes", 1, 4, 0, 0, 0, 3, 0, 48, 0, 0, 0 }; + } + + feed("ld<c-v>2j") + + check_events { + { "test1", "bytes", 1, 5, 0, 1, 1, 0, 1, 1, 0, 0, 0 }; + { "test1", "bytes", 1, 5, 1, 1, 16, 0, 1, 1, 0, 0, 0 }; + { "test1", "bytes", 1, 5, 2, 1, 31, 0, 1, 1, 0, 0, 0 }; + } + + feed("vjwd") + + check_events { + { "test1", "bytes", 1, 10, 0, 1, 1, 1, 9, 23, 0, 0, 0 }; + } + end) + it("changing lines", function() local check_events = setup_eventcheck(verify, origlines) @@ -889,6 +919,23 @@ describe('lua: nvim_buf_attach on_bytes', function() end) + it("flushes deleted bytes on move", function() + local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC", "DDD"}) + + feed(":.move+1<cr>") + + check_events { + { "test1", "bytes", 1, 5, 0, 0, 0, 1, 0, 4, 0, 0, 0 }; + { "test1", "bytes", 1, 5, 1, 0, 4, 0, 0, 0, 1, 0, 4 }; + } + + feed("jd2j") + + check_events { + { "test1", "bytes", 1, 6, 2, 0, 8, 2, 0, 8, 0, 0, 0 }; + } + end) + teardown(function() os.remove "Xtest-reload" os.remove "Xtest-undofile" |