From edcc73e766438facc88db19000f054aa52ab8b13 Mon Sep 17 00:00:00 2001 From: Peter Hodge Date: Fri, 26 Jan 2018 20:36:11 +0100 Subject: API: Implement buffer updates Originally written by @phodge in https://github.com/neovim/neovim/pull/5269. --- src/nvim/fold.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/nvim/fold.c') diff --git a/src/nvim/fold.c b/src/nvim/fold.c index ad9cd4d562..5758a298ac 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/liveupdate.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 LiveUpdate at the end + if (kv_size(curbuf->liveupdate_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; + liveupdate_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->liveupdate_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 LiveUpdate + // anyway since it won't do any harm. + int64_t num_changed = 1 + end - start; + liveupdate_send_changes(curbuf, start, num_changed, num_changed, true); + } } /* foldAddMarker() {{{2 */ -- cgit From 6bdcbef2f5acfd9815599c751bd8dcbe3204281f Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 11 Feb 2018 22:51:29 +0100 Subject: The grand renaming --- src/nvim/fold.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/fold.c') diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 5758a298ac..2cf1c6f394 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -20,7 +20,7 @@ #include "nvim/ex_docmd.h" #include "nvim/func_attr.h" #include "nvim/indent.h" -#include "nvim/liveupdate.h" +#include "nvim/buffer_updates.h" #include "nvim/mark.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -746,14 +746,14 @@ deleteFold ( if (last_lnum > 0) { changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L, false); - // send one LiveUpdate at the end - if (kv_size(curbuf->liveupdate_channels)) { + // send one nvim_buf_update 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; - liveupdate_send_changes(curbuf, first_lnum, num_changed, + buffer_updates_send_changes(curbuf, first_lnum, num_changed, num_changed, true); } } @@ -1605,12 +1605,12 @@ static void foldCreateMarkers(linenr_T start, linenr_T end) * changed when the start marker is inserted and the end isn't. */ changed_lines(start, (colnr_T)0, end, 0L, false); - if (kv_size(curbuf->liveupdate_channels)) { + 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 LiveUpdate + // u_save() is unable to save the buffer line, but we send the nvim_buf_update // anyway since it won't do any harm. int64_t num_changed = 1 + end - start; - liveupdate_send_changes(curbuf, start, num_changed, num_changed, true); + buffer_updates_send_changes(curbuf, start, num_changed, num_changed, true); } } -- cgit From 2106bada5bbd6de4729a8714d011e0eca61cee35 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 11 Feb 2018 23:02:53 +0100 Subject: Enable -Wconversion --- src/nvim/fold.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/fold.c') diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 2cf1c6f394..9869e0fd30 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -754,7 +754,7 @@ deleteFold ( // notification that includes every line that was part of the fold int64_t num_changed = last_lnum - first_lnum; buffer_updates_send_changes(curbuf, first_lnum, num_changed, - num_changed, true); + num_changed, true); } } } @@ -1607,8 +1607,8 @@ static void foldCreateMarkers(linenr_T start, linenr_T end) 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_update - // anyway since it won't do any harm. + // u_save() is unable to save the buffer line, but we send the + // nvim_buf_update anyway since it won't do any harm. int64_t num_changed = 1 + end - start; buffer_updates_send_changes(curbuf, start, num_changed, num_changed, true); } -- cgit From e7451f8a91e0a9452fc3c3627ac60dc80288252c Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Tue, 24 Apr 2018 20:38:00 +0200 Subject: Some renamings and doc changes --- src/nvim/fold.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/fold.c') diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 9869e0fd30..4d947d9b07 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -753,7 +753,7 @@ deleteFold ( // 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; - buffer_updates_send_changes(curbuf, first_lnum, num_changed, + buf_updates_send_changes(curbuf, first_lnum, num_changed, num_changed, true); } } @@ -1610,7 +1610,7 @@ static void foldCreateMarkers(linenr_T start, linenr_T end) // u_save() is unable to save the buffer line, but we send the // nvim_buf_update anyway since it won't do any harm. int64_t num_changed = 1 + end - start; - buffer_updates_send_changes(curbuf, start, num_changed, num_changed, true); + buf_updates_send_changes(curbuf, start, num_changed, num_changed, true); } } -- cgit From 491efc89d2e8da319077f7c6d93f07a01b543ab0 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Tue, 24 Apr 2018 21:45:36 +0200 Subject: Lint --- src/nvim/fold.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/fold.c') diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 4d947d9b07..32ba665f64 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -754,7 +754,7 @@ deleteFold ( // 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); + num_changed, true); } } } -- cgit From 65e7f6f0b97b02e323488e06bf0f5df93bbcbf93 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Fri, 18 May 2018 10:09:11 +0200 Subject: Rename some more, fixe borked renaming --- src/nvim/fold.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/fold.c') diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 32ba665f64..b8ace511e8 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -746,7 +746,7 @@ deleteFold ( if (last_lnum > 0) { changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L, false); - // send one nvim_buf_update at the end + // 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 @@ -1608,7 +1608,7 @@ static void foldCreateMarkers(linenr_T start, linenr_T end) 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_update anyway since it won't do any harm. + // 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); } -- cgit