diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-06-08 10:13:04 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-06-08 10:13:04 +0200 |
commit | f85cbea725b4d21412dc0ddfd07239307b3b63a4 (patch) | |
tree | cb88d8d6a010490160b9f7d0b1a236d61d29b323 /src/nvim/fold.c | |
parent | c500f22f3ced8bbc271c4ec50d2217626ba5e97e (diff) | |
parent | 2ca62239675b0c1e68b01aae1a0d45567b15e319 (diff) | |
download | rneovim-f85cbea725b4d21412dc0ddfd07239307b3b63a4.tar.gz rneovim-f85cbea725b4d21412dc0ddfd07239307b3b63a4.tar.bz2 rneovim-f85cbea725b4d21412dc0ddfd07239307b3b63a4.zip |
Merge #7917 'API: buffer updates'
Diffstat (limited to 'src/nvim/fold.c')
-rw-r--r-- | src/nvim/fold.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 316fbef47c..52ed2fe3dc 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -20,6 +20,7 @@ #include "nvim/ex_docmd.h" #include "nvim/func_attr.h" #include "nvim/indent.h" +#include "nvim/buffer_updates.h" #include "nvim/mark.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -742,8 +743,20 @@ deleteFold ( /* Deleting markers may make cursor column invalid. */ check_cursor_col(); - if (last_lnum > 0) - changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L); + if (last_lnum > 0) { + changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L, false); + + // send one nvim_buf_lines_event at the end + if (kv_size(curbuf->update_channels)) { + // last_lnum is the line *after* the last line of the outermost fold + // that was modified. Note also that deleting a fold might only require + // the modification of the *first* line of the fold, but we send through a + // notification that includes every line that was part of the fold + int64_t num_changed = last_lnum - first_lnum; + buf_updates_send_changes(curbuf, first_lnum, num_changed, + num_changed, true); + } + } } /* clearFolding() {{{2 */ @@ -1590,7 +1603,15 @@ static void foldCreateMarkers(linenr_T start, linenr_T end) /* Update both changes here, to avoid all folds after the start are * changed when the start marker is inserted and the end isn't. */ - changed_lines(start, (colnr_T)0, end, 0L); + changed_lines(start, (colnr_T)0, end, 0L, false); + + if (kv_size(curbuf->update_channels)) { + // Note: foldAddMarker() may not actually change start and/or end if + // u_save() is unable to save the buffer line, but we send the + // nvim_buf_lines_event anyway since it won't do any harm. + int64_t num_changed = 1 + end - start; + buf_updates_send_changes(curbuf, start, num_changed, num_changed, true); + } } /* foldAddMarker() {{{2 */ |