aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index f575d58f05..d68dbc8676 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -35,6 +35,7 @@
#include "nvim/fold.h"
#include "nvim/getchar.h"
#include "nvim/indent.h"
+#include "nvim/liveupdate.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
@@ -279,7 +280,7 @@ void ex_align(exarg_T *eap)
new_indent = 0;
(void)set_indent(new_indent, 0); /* set indent */
}
- changed_lines(eap->line1, 0, eap->line2 + 1, 0L);
+ changed_lines(eap->line1, 0, eap->line2 + 1, 0L, true);
curwin->w_cursor = save_curpos;
beginline(BL_WHITE | BL_FIX);
}
@@ -612,7 +613,7 @@ void ex_sort(exarg_T *eap)
} else if (deleted < 0) {
mark_adjust(eap->line2, MAXLNUM, -deleted, 0L, false);
}
- changed_lines(eap->line1, 0, eap->line2 + 1, -deleted);
+ changed_lines(eap->line1, 0, eap->line2 + 1, -deleted, true);
curwin->w_cursor.lnum = eap->line1;
beginline(BL_WHITE | BL_FIX);
@@ -745,7 +746,7 @@ void ex_retab(exarg_T *eap)
if (curbuf->b_p_ts != new_ts)
redraw_curbuf_later(NOT_VALID);
if (first_line != 0)
- changed_lines(first_line, 0, last_line + 1, 0L);
+ changed_lines(first_line, 0, last_line + 1, 0L, true);
curwin->w_p_list = save_list; /* restore 'list' */
@@ -806,6 +807,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
*/
last_line = curbuf->b_ml.ml_line_count;
mark_adjust_nofold(line1, line2, last_line - line2, 0L, true);
+ changed_lines(last_line - num_lines + 1, 0, last_line + 1, num_lines, false);
if (dest >= line2) {
mark_adjust_nofold(line2 + 1, dest, -num_lines, 0L, false);
FOR_ALL_TAB_WINDOWS(tab, win) {
@@ -828,6 +830,12 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
mark_adjust_nofold(last_line - num_lines + 1, last_line,
-(last_line - dest - extra), 0L, true);
+ changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra, false);
+
+ // send live update regarding the new lines that were added
+ if (kv_size(curbuf->liveupdate_channels)) {
+ liveupdate_send_changes(curbuf, dest + 1, num_lines, 0, true);
+ }
/*
* Now we delete the original text -- webb
@@ -858,9 +866,14 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
last_line = curbuf->b_ml.ml_line_count;
if (dest > last_line + 1)
dest = last_line + 1;
- changed_lines(line1, 0, dest, 0L);
+ changed_lines(line1, 0, dest, 0L, false);
} else {
- changed_lines(dest + 1, 0, line1 + num_lines, 0L);
+ changed_lines(dest + 1, 0, line1 + num_lines, 0L, false);
+ }
+
+ // send LiveUpdate regarding lines that were deleted
+ if (kv_size(curbuf->liveupdate_channels)) {
+ liveupdate_send_changes(curbuf, line1 + extra, 0, num_lines, true);
}
return OK;
@@ -2428,6 +2441,7 @@ int do_ecmd(
goto theend;
}
u_unchanged(curbuf);
+ liveupdate_unregister_all(curbuf);
buf_freeall(curbuf, BFA_KEEP_UNDO);
// Tell readfile() not to clear or reload undo info.
@@ -3154,7 +3168,8 @@ static char_u *sub_parse_flags(char_u *cmd, subflags_T *subflags,
/// The usual escapes are supported as described in the regexp docs.
///
/// @return buffer used for 'inccommand' preview
-static buf_T *do_sub(exarg_T *eap, proftime_T timeout)
+static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
+ bool send_liveupdate_changedtick)
{
long i = 0;
regmmatch_T regmatch;
@@ -4000,7 +4015,14 @@ skip:
* the line number before the change (same as adding the number of
* deleted lines). */
i = curbuf->b_ml.ml_line_count - old_line_count;
- changed_lines(first_line, 0, last_line - i, i);
+ changed_lines(first_line, 0, last_line - i, i, false);
+
+ if (kv_size(curbuf->liveupdate_channels)) {
+ int64_t num_added = last_line - first_line;
+ int64_t num_removed = num_added - i;
+ liveupdate_send_changes(curbuf, first_line, num_added, num_removed,
+ send_liveupdate_changedtick);
+ }
}
xfree(sub_firstline); /* may have to free allocated copy of the line */
@@ -6246,7 +6268,7 @@ void ex_substitute(exarg_T *eap)
{
bool preview = (State & CMDPREVIEW);
if (*p_icm == NUL || !preview) { // 'inccommand' is disabled
- (void)do_sub(eap, profile_zero());
+ (void)do_sub(eap, profile_zero(), true);
return;
}
@@ -6270,7 +6292,7 @@ void ex_substitute(exarg_T *eap)
// Don't show search highlighting during live substitution
bool save_hls = p_hls;
p_hls = false;
- buf_T *preview_buf = do_sub(eap, profile_setlimit(p_rdt));
+ buf_T *preview_buf = do_sub(eap, profile_setlimit(p_rdt), false);
p_hls = save_hls;
if (save_changedtick != curbuf->b_changedtick) {