aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthieu Coudron <mattator@gmail.com>2020-06-06 02:05:49 +0200
committerGitHub <noreply@github.com>2020-06-06 02:05:49 +0200
commit33dafc4f0f21f763dac8f6bdbd27117666f908c5 (patch)
tree179301040b52babddbe60001bc5c9b467edc310a /src
parentfca471d8e2573c2351151051a2d2c6eee0b2243b (diff)
parent9538a7895cb6af2312a39c4c0710ace638309914 (diff)
downloadrneovim-33dafc4f0f21f763dac8f6bdbd27117666f908c5.tar.gz
rneovim-33dafc4f0f21f763dac8f6bdbd27117666f908c5.tar.bz2
rneovim-33dafc4f0f21f763dac8f6bdbd27117666f908c5.zip
Merge pull request #12413 from janlazo/vim-8.2.0089
[RDY]vim-patch:8.0.1564,8.1.{917,1895,2018,2335},8.2.{89,491,873,892,905}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c11
-rw-r--r--src/nvim/eval.c3
-rw-r--r--src/nvim/eval/userfunc.c3
-rw-r--r--src/nvim/ex_getln.c6
-rw-r--r--src/nvim/globals.h4
-rw-r--r--src/nvim/main.c7
-rw-r--r--src/nvim/message.c5
-rw-r--r--src/nvim/normal.c15
-rw-r--r--src/nvim/os/signal.c1
-rw-r--r--src/nvim/regexp_nfa.c6
-rw-r--r--src/nvim/syntax.c4
-rw-r--r--src/nvim/testdir/test_cmdline.vim16
-rw-r--r--src/nvim/testdir/test_filetype.vim2
-rw-r--r--src/nvim/testdir/test_ga.vim1
-rw-r--r--src/nvim/testdir/test_maparg.vim8
15 files changed, 62 insertions, 30 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 7c8f93163a..3ce39feda5 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -186,14 +186,17 @@ int open_buffer(
}
}
- /*
- * if there is no memfile at all, exit
- * This is OK, since there are no changes to lose.
- */
+ // If there is no memfile at all, exit.
+ // This is OK, since there are no changes to lose.
if (curbuf == NULL) {
EMSG(_("E82: Cannot allocate any buffer, exiting..."));
+
+ // Don't try to do any saving, with "curbuf" NULL almost nothing
+ // will work.
+ v_dying = 2;
getout(2);
}
+
EMSG(_("E83: Cannot allocate buffer, using other one..."));
enter_buffer(curbuf);
if (old_tw != curbuf->b_p_tw) {
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 017d46e802..5f8f3f96f7 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -6120,7 +6120,7 @@ void common_function(typval_T *argvars, typval_T *rettv,
if (tv_list_len(list) == 0) {
arg_idx = 0;
} else if (tv_list_len(list) > MAX_FUNC_ARGS) {
- emsg_funcname((char *)e_toomanyarg, name);
+ emsg_funcname((char *)e_toomanyarg, s);
xfree(name);
goto theend;
}
@@ -6754,6 +6754,7 @@ void mapblock_fill_dict(dict_T *const dict,
}
tv_dict_add_allocated_str(dict, S_LEN("lhs"), lhs);
tv_dict_add_nr(dict, S_LEN("noremap"), noremap_value);
+ tv_dict_add_nr(dict, S_LEN("script"), mp->m_noremap == REMAP_SCRIPT ? 1 : 0);
tv_dict_add_nr(dict, S_LEN("expr"), mp->m_expr ? 1 : 0);
tv_dict_add_nr(dict, S_LEN("silent"), mp->m_silent ? 1 : 0);
tv_dict_add_nr(dict, S_LEN("sid"), (varnumber_T)mp->m_script_ctx.sc_sid);
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index c054433255..4d658498c1 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -170,6 +170,7 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
garray_T newargs = GA_EMPTY_INIT_VALUE;
garray_T *pnewargs;
ufunc_T *fp = NULL;
+ partial_T *pt = NULL;
int varargs;
int ret;
char_u *start = skipwhite(*arg + 1);
@@ -219,7 +220,6 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
int len, flags = 0;
char_u *p;
char_u name[20];
- partial_T *pt;
garray_T newlines;
lambda_no++;
@@ -274,6 +274,7 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
errret:
ga_clear_strings(&newargs);
xfree(fp);
+ xfree(pt);
eval_lavars_used = old_eval_lavars;
return FAIL;
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index b799e86ff7..56a8f56753 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -5361,12 +5361,12 @@ void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options)
// Concatenate new results to previous ones.
ga_grow(ga, num_p);
+ // take over the pointers and put them in "ga"
for (int i = 0; i < num_p; i++) {
- ((char_u **)ga->ga_data)[ga->ga_len] = vim_strsave(p[i]);
+ ((char_u **)ga->ga_data)[ga->ga_len] = p[i];
ga->ga_len++;
}
-
- FreeWild(num_p, p);
+ xfree(p);
}
}
}
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index f102c3ddd8..d6d00d6e83 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -203,7 +203,7 @@ EXTERN int msg_nowait INIT(= false); // don't wait for this msg
EXTERN int emsg_off INIT(= 0); // don't display errors for now,
// unless 'debug' is set.
EXTERN int info_message INIT(= false); // printing informative message
-EXTERN int msg_hist_off INIT(= false); // don't add messages to history
+EXTERN bool msg_hist_off INIT(= false); // don't add messages to history
EXTERN int need_clr_eos INIT(= false); // need to clear text before
// displaying a message.
EXTERN int emsg_skip INIT(= 0); // don't display errors for
@@ -478,6 +478,8 @@ EXTERN int sc_col; // column for shown command
EXTERN int starting INIT(= NO_SCREEN);
// true when planning to exit. Might keep running if there is a changed buffer.
EXTERN bool exiting INIT(= false);
+// internal value of v:dying
+EXTERN int v_dying INIT(= 0);
// is stdin a terminal?
EXTERN int stdin_isatty INIT(= true);
// is stdout a terminal?
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 6ac9cdfbae..b3a903cbe3 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -621,7 +621,7 @@ void getout(int exitval)
/* Optionally print hashtable efficiency. */
hash_debug_results();
- if (get_vim_var_nr(VV_DYING) <= 1) {
+ if (v_dying <= 1) {
const tabpage_T *next_tp;
// Trigger BufWinLeave for all windows, but only once per buffer.
@@ -670,8 +670,9 @@ void getout(int exitval)
shada_write_file(NULL, false);
}
- if (get_vim_var_nr(VV_DYING) <= 1)
- apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf);
+ if (v_dying <= 1) {
+ apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, false, curbuf);
+ }
profile_dump();
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 9aa588e035..8999365d32 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -306,11 +306,6 @@ bool msg_attr_keep(char_u *s, int attr, bool keep, bool multiline)
add_msg_hist((const char *)s, -1, attr, multiline);
}
- /* When displaying keep_msg, don't let msg_start() free it, caller must do
- * that. */
- if (s == keep_msg)
- keep_msg = NULL;
-
/* Truncate the message if needed. */
msg_start();
buf = msg_strtrunc(s, FALSE);
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 87d687198d..968cfde388 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -621,6 +621,8 @@ static void normal_redraw_mode_message(NormalState *s)
update_screen(0);
// now reset it, otherwise it's put in the history again
keep_msg = kmsg;
+
+ kmsg = vim_strsave(keep_msg);
msg_attr((const char *)kmsg, keep_msg_attr);
xfree(kmsg);
}
@@ -1265,10 +1267,15 @@ static void normal_redraw(NormalState *s)
// Display message after redraw. If an external message is still visible,
// it contains the kept message already.
if (keep_msg != NULL && !msg_ext_is_visible()) {
- // msg_attr_keep() will set keep_msg to NULL, must free the string here.
- // Don't reset keep_msg, msg_attr_keep() uses it to check for duplicates.
- char *p = (char *)keep_msg;
- msg_attr(p, keep_msg_attr);
+ char_u *const p = vim_strsave(keep_msg);
+
+ // msg_start() will set keep_msg to NULL, make a copy
+ // first. Don't reset keep_msg, msg_attr_keep() uses it to
+ // check for duplicates. Never put this message in
+ // history.
+ msg_hist_off = true;
+ msg_attr((const char *)p, keep_msg_attr);
+ msg_hist_off = false;
xfree(p);
}
diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c
index 112de9fed8..bfe230b521 100644
--- a/src/nvim/os/signal.c
+++ b/src/nvim/os/signal.c
@@ -157,6 +157,7 @@ static void deadly_signal(int signum)
{
// Set the v:dying variable.
set_vim_var_nr(VV_DYING, 1);
+ v_dying = 1;
WLOG("got signal %d (%s)", signum, signal_name(signum));
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index f33c61d39f..2ca5f42e51 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -249,6 +249,7 @@ static char_u e_nul_found[] = N_(
static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
static char_u e_ill_char_class[] = N_(
"E877: (NFA regexp) Invalid character class: %" PRId64);
+static char_u e_value_too_large[] = N_("E951: \\% value too large");
/* Since the out pointers in the list are always
* uninitialized, we use the pointers themselves
@@ -1499,7 +1500,8 @@ static int nfa_regatom(void)
c = getchr();
while (ascii_isdigit(c)) {
if (n > (INT32_MAX - (c - '0')) / 10) {
- EMSG(_("E951: \\% value too large"));
+ // overflow.
+ EMSG(_(e_value_too_large));
return FAIL;
}
n = n * 10 + (c - '0');
@@ -1526,7 +1528,7 @@ static int nfa_regatom(void)
limit = INT32_MAX / MB_MAXBYTES;
}
if (n >= limit) {
- EMSG(_("E951: \\% value too large"));
+ EMSG(_(e_value_too_large));
return FAIL;
}
EMIT((int)n);
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index ef4dfb3caa..f3b05c3961 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -7444,6 +7444,8 @@ static int syn_add_group(char_u *name)
return 0;
}
+ char_u *const name_up = vim_strsave_up(name);
+
// Append another syntax_highlight entry.
struct hl_group* hlgp = GA_APPEND_VIA_PTR(struct hl_group, &highlight_ga);
memset(hlgp, 0, sizeof(*hlgp));
@@ -7452,7 +7454,7 @@ static int syn_add_group(char_u *name)
hlgp->sg_rgb_fg = -1;
hlgp->sg_rgb_sp = -1;
hlgp->sg_blend = -1;
- hlgp->sg_name_u = vim_strsave_up(name);
+ hlgp->sg_name_u = name_up;
return highlight_ga.ga_len; /* ID is index plus one */
}
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 2c7d64f078..f8d84f1a49 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -692,6 +692,22 @@ func Test_getcmdwin_autocmd()
augroup END
endfunc
+" Test error: "E135: *Filter* Autocommands must not change current buffer"
+func Test_cmd_bang_E135()
+ new
+ call setline(1, ['a', 'b', 'c', 'd'])
+ augroup test_cmd_filter_E135
+ au!
+ autocmd FilterReadPost * help
+ augroup END
+ call assert_fails('2,3!echo "x"', 'E135:')
+
+ augroup test_cmd_filter_E135
+ au!
+ augroup END
+ %bwipe!
+endfunc
+
func Test_verbosefile()
set verbosefile=Xlog
echomsg 'foo'
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 832f1726fb..ffd2cee80f 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -252,7 +252,7 @@ let s:filename_checks = {
\ 'lilo': ['lilo.conf'],
\ 'limits': ['/etc/limits', '/etc/anylimits.conf', '/etc/anylimits.d/file.conf'],
\ 'liquid': ['file.liquid'],
- \ 'lisp': ['sbclrc', '.sbclrc'],
+ \ 'lisp': ['file.lsp', 'file.lisp', 'file.el', 'file.cl', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc'],
\ 'lite': ['file.lite', 'file.lt'],
\ 'litestep': ['/LiteStep/any/file.rc'],
\ 'loginaccess': ['/etc/login.access'],
diff --git a/src/nvim/testdir/test_ga.vim b/src/nvim/testdir/test_ga.vim
index ea3d211aeb..87f1382342 100644
--- a/src/nvim/testdir/test_ga.vim
+++ b/src/nvim/testdir/test_ga.vim
@@ -24,6 +24,7 @@ func Test_ga_command()
" Test a few multi-bytes characters.
call assert_equal("\n<é> 233, Hex 00e9, Oct 351, Digr e'", Do_ga('é'))
call assert_equal("\n<ẻ> 7867, Hex 1ebb, Oct 17273, Digr e2", Do_ga('ẻ'))
+ call assert_equal("\n<\U00012345> 74565, Hex 00012345, Octal 221505", Do_ga("\U00012345"))
" Test with combining characters.
call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401", Do_ga("e\u0301"))
diff --git a/src/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim
index 5f73bd80ad..238d2f900d 100644
--- a/src/nvim/testdir/test_maparg.vim
+++ b/src/nvim/testdir/test_maparg.vim
@@ -15,23 +15,23 @@ function Test_maparg()
map foo<C-V> is<F4>foo
vnoremap <script> <buffer> <expr> <silent> bar isbar
call assert_equal("is<F4>foo", maparg('foo<C-V>'))
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>',
\ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1,
\ 'rhs': 'is<F4>foo', 'buffer': 0},
\ maparg('foo<C-V>', '', 0, 1))
- call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v',
+ call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', 'mode': 'v',
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
\ 'rhs': 'isbar', 'buffer': 1},
\ maparg('bar', '', 0, 1))
let lnum = expand('<sflnum>')
map <buffer> <nowait> foo bar
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', 'mode': ' ',
\ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar',
\ 'buffer': 1},
\ maparg('foo', '', 0, 1))
let lnum = expand('<sflnum>')
tmap baz foo
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'baz', 'mode': 't',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz', 'mode': 't',
\ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo',
\ 'buffer': 0},
\ maparg('baz', 't', 0, 1))