aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-02-10 20:56:54 -0500
committerGitHub <noreply@github.com>2021-02-10 20:56:54 -0500
commit1aec5ba85e97889c792253424c5de9c12ddd6cf4 (patch)
tree62c78074f611cb812eb630f6e1c88eeabeae06bd /src
parent61aea004d7101e138794a337c03ef00a6b3994e6 (diff)
parent81b4c881302640747de39f805312966c541acc47 (diff)
downloadrneovim-1aec5ba85e97889c792253424c5de9c12ddd6cf4.tar.gz
rneovim-1aec5ba85e97889c792253424c5de9c12ddd6cf4.tar.bz2
rneovim-1aec5ba85e97889c792253424c5de9c12ddd6cf4.zip
Merge pull request #13908 from janlazo/vim-8.2.2489
vim-patch:8.1.0341,8.2.{2489,2490,2492,2495,2496}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/diff.c21
-rw-r--r--src/nvim/eval/funcs.c33
-rw-r--r--src/nvim/ex_cmds2.c34
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/move.c4
-rw-r--r--src/nvim/testdir/test_arglist.vim18
-rw-r--r--src/nvim/testdir/test_breakindent.vim9
-rw-r--r--src/nvim/testdir/test_bufline.vim11
-rw-r--r--src/nvim/testdir/test_command_count.vim4
-rw-r--r--src/nvim/testdir/test_diffmode.vim15
10 files changed, 105 insertions, 46 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 358725239c..31b7b1bd8f 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -58,6 +58,7 @@ static bool diff_need_update = false; // ex_diffupdate needs to be called
#define DIFF_HIDDEN_OFF 0x100 // diffoff when hidden
#define DIFF_INTERNAL 0x200 // use internal xdiff algorithm
#define DIFF_CLOSE_OFF 0x400 // diffoff when closing window
+#define DIFF_FOLLOWWRAP 0x800 // follow the wrap option
#define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF;
@@ -1361,11 +1362,12 @@ void diff_win_options(win_T *wp, int addbuf)
wp->w_p_crb_save = wp->w_p_crb;
}
wp->w_p_crb = true;
-
- if (!wp->w_p_diff) {
- wp->w_p_wrap_save = wp->w_p_wrap;
+ if (!(diff_flags & DIFF_FOLLOWWRAP)) {
+ if (!wp->w_p_diff) {
+ wp->w_p_wrap_save = wp->w_p_wrap;
+ }
+ wp->w_p_wrap = false;
}
- wp->w_p_wrap = false;
curwin = wp; // -V519
curbuf = curwin->w_buffer;
@@ -1437,11 +1439,11 @@ void ex_diffoff(exarg_T *eap)
if (wp->w_p_crb) {
wp->w_p_crb = wp->w_p_crb_save;
}
-
- if (!wp->w_p_wrap) {
- wp->w_p_wrap = wp->w_p_wrap_save;
+ if (!(diff_flags & DIFF_FOLLOWWRAP)) {
+ if (!wp->w_p_wrap) {
+ wp->w_p_wrap = wp->w_p_wrap_save;
+ }
}
-
free_string_option(wp->w_p_fdm);
wp->w_p_fdm = vim_strsave(*wp->w_p_fdm_save
? wp->w_p_fdm_save
@@ -2158,6 +2160,9 @@ int diffopt_changed(void)
} else if (STRNCMP(p, "closeoff", 8) == 0) {
p += 8;
diff_flags_new |= DIFF_CLOSE_OFF;
+ } else if (STRNCMP(p, "followwrap", 10) == 0) {
+ p += 10;
+ diff_flags_new |= DIFF_FOLLOWWRAP;
} else if (STRNCMP(p, "indent-heuristic", 16) == 0) {
p += 16;
diff_indent_heuristic = XDF_INDENT_HEURISTIC;
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index fae5711b9c..3cc71a39f6 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -1629,27 +1629,26 @@ static void f_deletebufline(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (u_save(first - 1, last + 1) == FAIL) {
rettv->vval.v_number = 1; // FAIL
- return;
- }
-
- for (linenr_T lnum = first; lnum <= last; lnum++) {
- ml_delete(first, true);
- }
+ } else {
+ for (linenr_T lnum = first; lnum <= last; lnum++) {
+ ml_delete(first, true);
+ }
- FOR_ALL_TAB_WINDOWS(tp, wp) {
- if (wp->w_buffer == buf) {
- if (wp->w_cursor.lnum > last) {
- wp->w_cursor.lnum -= count;
- } else if (wp->w_cursor.lnum> first) {
- wp->w_cursor.lnum = first;
- }
- if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count) {
- wp->w_cursor.lnum = wp->w_buffer->b_ml.ml_line_count;
+ FOR_ALL_TAB_WINDOWS(tp, wp) {
+ if (wp->w_buffer == buf) {
+ if (wp->w_cursor.lnum > last) {
+ wp->w_cursor.lnum -= count;
+ } else if (wp->w_cursor.lnum> first) {
+ wp->w_cursor.lnum = first;
+ }
+ if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count) {
+ wp->w_cursor.lnum = wp->w_buffer->b_ml.ml_line_count;
+ }
}
}
+ check_cursor_col();
+ deleted_lines_mark(first, count);
}
- check_cursor_col();
- deleted_lines_mark(first, count);
if (!is_curbuf) {
curbuf = curbuf_save;
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 2598b13079..bb53f4d373 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -1657,9 +1657,11 @@ int get_arglist_exp(char_u *str, int *fcountp, char_u ***fnamesp, bool wig)
/// AL_DEL: remove files in 'str' from the argument list.
/// @param after
/// 0 means before first one
+/// @param will_edit will edit added argument
///
/// @return FAIL for failure, OK otherwise.
-static int do_arglist(char_u *str, int what, int after)
+static int do_arglist(char_u *str, int what, int after, bool will_edit)
+ FUNC_ATTR_NONNULL_ALL
{
garray_T new_ga;
int exp_count;
@@ -1733,10 +1735,11 @@ static int do_arglist(char_u *str, int what, int after)
}
if (what == AL_ADD) {
- (void)alist_add_list(exp_count, exp_files, after);
+ alist_add_list(exp_count, exp_files, after, will_edit);
xfree(exp_files);
- } else { // what == AL_SET
- alist_set(ALIST(curwin), exp_count, exp_files, false, NULL, 0);
+ } else {
+ assert(what == AL_SET);
+ alist_set(ALIST(curwin), exp_count, exp_files, will_edit, NULL, 0);
}
}
@@ -1956,7 +1959,7 @@ void ex_next(exarg_T *eap)
| (eap->forceit ? CCGD_FORCEIT : 0)
| CCGD_EXCMD)) {
if (*eap->arg != NUL) { // redefine file list
- if (do_arglist(eap->arg, AL_SET, 0) == FAIL) {
+ if (do_arglist(eap->arg, AL_SET, 0, true) == FAIL) {
return;
}
i = 0;
@@ -1974,7 +1977,7 @@ void ex_argedit(exarg_T *eap)
// Whether curbuf will be reused, curbuf->b_ffname will be set.
bool curbuf_is_reusable = curbuf_reusable();
- if (do_arglist(eap->arg, AL_ADD, i) == FAIL) {
+ if (do_arglist(eap->arg, AL_ADD, i, true) == FAIL) {
return;
}
maketitle();
@@ -1994,7 +1997,8 @@ void ex_argedit(exarg_T *eap)
void ex_argadd(exarg_T *eap)
{
do_arglist(eap->arg, AL_ADD,
- eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1);
+ eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1,
+ false);
maketitle();
}
@@ -2041,7 +2045,7 @@ void ex_argdelete(exarg_T *eap)
}
}
} else {
- do_arglist(eap->arg, AL_DEL, 0);
+ do_arglist(eap->arg, AL_DEL, 0, false);
}
maketitle();
}
@@ -2292,9 +2296,9 @@ void ex_listdo(exarg_T *eap)
/// Files[] itself is not taken over.
///
/// @param after: where to add: 0 = before first one
-///
-/// @return index of first added argument
-static int alist_add_list(int count, char_u **files, int after)
+/// @param will_edit will edit adding argument
+static void alist_add_list(int count, char_u **files, int after, bool will_edit)
+ FUNC_ATTR_NONNULL_ALL
{
int old_argcount = ARGCOUNT;
ga_grow(&ALIST(curwin)->al_ga, count);
@@ -2310,15 +2314,15 @@ static int alist_add_list(int count, char_u **files, int after)
(size_t)(ARGCOUNT - after) * sizeof(aentry_T));
}
for (int i = 0; i < count; i++) {
+ const int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0);
ARGLIST[after + i].ae_fname = files[i];
- ARGLIST[after + i].ae_fnum = buflist_add(files[i],
- BLN_LISTED | BLN_CURBUF);
+ ARGLIST[after + i].ae_fnum = buflist_add(files[i], flags);
}
ALIST(curwin)->al_ga.ga_len += count;
if (old_argcount > 0 && curwin->w_arg_idx >= after) {
curwin->w_arg_idx += count;
}
- return after;
+ return;
}
}
@@ -3766,7 +3770,7 @@ void ex_drop(exarg_T *eap)
// and mostly only one file is dropped.
// This also ignores wildcards, since it is very unlikely the user is
// editing a file name with a wildcard character.
- do_arglist(eap->arg, AL_SET, 0);
+ do_arglist(eap->arg, AL_SET, 0, false);
// Expanding wildcards may result in an empty argument list. E.g. when
// editing "foo.pyc" and ".pyc" is in 'wildignore'. Assume that we
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 7776191869..4d1fd9b33f 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -6441,7 +6441,7 @@ static int open_cmdwin(void)
cmdwin_level = ccline.level;
// Create empty command-line buffer.
- buf_open_scratch(0, "[Command Line]");
+ buf_open_scratch(0, _("[Command Line]"));
// Command-line buffer has bufhidden=wipe, unlike a true "scratch" buffer.
set_option_value("bh", 0L, "wipe", OPT_LOCAL);
curwin->w_p_rl = cmdmsg_rl;
diff --git a/src/nvim/move.c b/src/nvim/move.c
index a6afdc27d9..1210a3365a 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -888,11 +888,11 @@ void curs_columns(
} else {
n = plines;
}
- if ((colnr_T)n >= wp->w_height_inner + wp->w_skipcol / width) {
+ if ((colnr_T)n >= wp->w_height_inner + wp->w_skipcol / width - so) {
extra += 2;
}
- if (extra == 3 || plines < so * 2) {
+ if (extra == 3 || plines <= so * 2) {
// not enough room for 'scrolloff', put cursor in the middle
n = wp->w_virtcol / width;
if (n > wp->w_height_inner / 2) {
diff --git a/src/nvim/testdir/test_arglist.vim b/src/nvim/testdir/test_arglist.vim
index 92fedf9bfb..a1ef8325ec 100644
--- a/src/nvim/testdir/test_arglist.vim
+++ b/src/nvim/testdir/test_arglist.vim
@@ -80,6 +80,24 @@ func Test_argadd()
call assert_equal(0, len(argv()))
endfunc
+func Test_argadd_empty_curbuf()
+ new
+ let curbuf = bufnr('%')
+ call writefile(['test', 'Xargadd'], 'Xargadd')
+ " must not re-use the current buffer.
+ argadd Xargadd
+ call assert_equal(curbuf, bufnr('%'))
+ call assert_equal('', bufname('%'))
+ call assert_equal(1, line('$'))
+ rew
+ call assert_notequal(curbuf, bufnr('%'))
+ call assert_equal('Xargadd', bufname('%'))
+ call assert_equal(2, line('$'))
+
+ %argd
+ bwipe!
+endfunc
+
func Init_abc()
args a b c
next
diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim
index a4c1f62a43..d53acb77d7 100644
--- a/src/nvim/testdir/test_breakindent.vim
+++ b/src/nvim/testdir/test_breakindent.vim
@@ -353,14 +353,19 @@ func Test_breakindent19_sbr_nextpage()
" Scroll down one screen line
setl scrolloff=5
norm! 5gj
- redraw!
let lines = s:screen_lines(1, 20)
let expect = [
- \ "> aaaaaaaaaaaaaaaaaa",
+ \ "aaaaaaaaaaaaaaaaaaaa",
\ "> aaaaaaaaaaaaaaaaaa",
\ "> aaaaaaaaaaaaaaaaaa",
\ ]
call s:compare_lines(expect, lines)
+ redraw!
+ " moving the cursor doesn't change the text offset
+ norm! l
+ redraw!
+ let lines = s:screen_lines(1, 20)
+ call s:compare_lines(expect, lines)
setl breakindent briopt=min:18 sbr=>
norm! 5gj
diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim
index 076f03fdd8..e038bce08e 100644
--- a/src/nvim/testdir/test_bufline.vim
+++ b/src/nvim/testdir/test_bufline.vim
@@ -112,6 +112,17 @@ func Test_deletebufline()
call assert_equal(0, deletebufline(b, 1))
call assert_equal(['b', 'c'], getbufline(b, 1, 2))
exe "bwipe! " . b
+
+ edit XbufOne
+ let one = bufnr()
+ call setline(1, ['a', 'b', 'c'])
+ setlocal nomodifiable
+ split XbufTwo
+ let two = bufnr()
+ call assert_fails('call deletebufline(one, 1)', 'E21:')
+ call assert_equal(two, bufnr())
+ bwipe! XbufTwo
+ bwipe! XbufOne
endfunc
func Test_appendbufline_redraw()
diff --git a/src/nvim/testdir/test_command_count.vim b/src/nvim/testdir/test_command_count.vim
index 7262789ab4..55b230373f 100644
--- a/src/nvim/testdir/test_command_count.vim
+++ b/src/nvim/testdir/test_command_count.vim
@@ -158,7 +158,9 @@ endfunc
func Test_command_count_4()
%argd
let bufnr = bufnr('$')
- arga aa bb cc dd ee ff
+ next aa bb cc dd ee ff
+ call assert_equal(bufnr, bufnr('%'))
+
3argu
let args = []
.,$-argdo call add(args, expand('%'))
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index f09a64c329..640de1bdc6 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -964,6 +964,21 @@ func Test_diff_closeoff()
enew!
endfunc
+func Test_diff_followwrap()
+ new
+ set diffopt+=followwrap
+ set wrap
+ diffthis
+ call assert_equal(1, &wrap)
+ diffoff
+ set nowrap
+ diffthis
+ call assert_equal(0, &wrap)
+ diffoff
+ set diffopt&
+ bwipe!
+endfunc
+
func Test_diff_rnu()
CheckScreendump