diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-01-14 12:45:09 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2020-01-16 12:36:10 +0100 |
commit | ca1a00edd6d6345b848a28d077d6a192528f811e (patch) | |
tree | 936ca7dda66f9dc5fdf0f63181e45b42cfe1016d /src/nvim/mark.c | |
parent | 55677ddc4637664c8ef034e5c91f79fae8a97396 (diff) | |
download | rneovim-ca1a00edd6d6345b848a28d077d6a192528f811e.tar.gz rneovim-ca1a00edd6d6345b848a28d077d6a192528f811e.tar.bz2 rneovim-ca1a00edd6d6345b848a28d077d6a192528f811e.zip |
extmarks/bufhl: reimplement using new marktree data structure
Add new "splice" interface for tracking buffer changes at the byte
level. This will later be reused for byte-resolution buffer updates.
(Implementation has been started, but using undocumented "_on_bytes"
option now as interface hasn't been finalized).
Use this interface to improve many edge cases of extmark adjustment.
Changed tests indicate previously incorrect behavior. Adding tests for
more edge cases will be follow-up work (overlaps on_bytes tests)
Don't consider creation/deletion of marks an undoable event by itself.
This behavior was never documented, and imposes complexity for little gain.
Add nvim__buf_add_decoration temporary API for direct access to the new
implementation. This should be refactored into a proper API for
decorations, probably involving a huge dict.
fixes #11598
Diffstat (limited to 'src/nvim/mark.c')
-rw-r--r-- | src/nvim/mark.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 8b2f342142..4a7452493a 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -20,6 +20,7 @@ #include "nvim/ex_cmds.h" #include "nvim/fileio.h" #include "nvim/fold.h" +#include "nvim/mark_extended.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -915,10 +916,9 @@ void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after, - bool end_temp, ExtmarkOp op) { - mark_adjust_internal(line1, line2, amount, amount_after, true, end_temp, op); + mark_adjust_internal(line1, line2, amount, amount_after, true, op); } // mark_adjust_nofold() does the same as mark_adjust() but without adjusting @@ -927,15 +927,15 @@ void mark_adjust(linenr_T line1, // calling foldMarkAdjust() with arguments line1, line2, amount, amount_after, // for an example of why this may be necessary, see do_move(). void mark_adjust_nofold(linenr_T line1, linenr_T line2, long amount, - long amount_after, bool end_temp, + long amount_after, ExtmarkOp op) { - mark_adjust_internal(line1, line2, amount, amount_after, false, end_temp, op); + mark_adjust_internal(line1, line2, amount, amount_after, false, op); } static void mark_adjust_internal(linenr_T line1, linenr_T line2, long amount, long amount_after, - bool adjust_folds, bool end_temp, + bool adjust_folds, ExtmarkOp op) { int i; @@ -991,9 +991,8 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, } sign_mark_adjust(line1, line2, amount, amount_after); - bufhl_mark_adjust(curbuf, line1, line2, amount, amount_after, end_temp); if (op != kExtmarkNOOP) { - extmark_adjust(curbuf, line1, line2, amount, amount_after, op, end_temp); + extmark_adjust(curbuf, line1, line2, amount, amount_after, op); } } @@ -1106,7 +1105,7 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, // cursor is inside them. void mark_col_adjust( linenr_T lnum, colnr_T mincol, long lnum_amount, long col_amount, - int spaces_removed, ExtmarkOp op) + int spaces_removed) { int i; int fnum = curbuf->b_fnum; @@ -1126,13 +1125,6 @@ void mark_col_adjust( col_adjust(&(namedfm[i].fmark.mark)); } - // Extmarks - if (op != kExtmarkNOOP) { - // TODO(timeyyy): consider spaces_removed? (behave like a delete) - extmark_col_adjust(curbuf, lnum, mincol, lnum_amount, col_amount, - kExtmarkUndo); - } - /* last Insert position */ col_adjust(&(curbuf->b_last_insert.mark)); |