aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c2
-rw-r--r--src/nvim/getchar.c29
-rw-r--r--src/nvim/search.c8
-rw-r--r--src/nvim/testdir/test_autocmd.vim19
-rw-r--r--src/nvim/testdir/test_cmdline.vim36
5 files changed, 69 insertions, 25 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 2a6ceb50f6..b315639681 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4614,7 +4614,7 @@ static void ex_doautocmd(exarg_T *eap)
int call_do_modelines = check_nomodeline(&arg);
bool did_aucmd;
- (void)do_doautocmd(arg, true, &did_aucmd);
+ (void)do_doautocmd(arg, false, &did_aucmd);
// Only when there is no <nomodeline>.
if (call_do_modelines && did_aucmd) {
do_modelines(0);
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 7d8342c4dd..f7614fd3e1 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -3558,11 +3558,9 @@ set_context_in_map_cmd (
return NULL;
}
-/*
- * Find all mapping/abbreviation names that match regexp 'prog'.
- * For command line expansion of ":[un]map" and ":[un]abbrev" in all modes.
- * Return OK if matches found, FAIL otherwise.
- */
+// Find all mapping/abbreviation names that match regexp "regmatch".
+// For command line expansion of ":[un]map" and ":[un]abbrev" in all modes.
+// Return OK if matches found, FAIL otherwise.
int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
{
mapblock_T *mp;
@@ -3622,7 +3620,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
mp = maphash[hash];
for (; mp; mp = mp->m_next) {
if (mp->m_mode & expand_mapmodes) {
- p = translate_mapping(mp->m_keys, true, CPO_TO_CPO_FLAGS);
+ p = translate_mapping(mp->m_keys, CPO_TO_CPO_FLAGS);
if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) {
if (round == 1)
++count;
@@ -4346,16 +4344,15 @@ void add_map(char_u *map, int mode)
// corresponding external one recognized by :map/:abbrev commands.
//
// This function is called when expanding mappings/abbreviations on the
-// command-line, and for building the "Ambiguous mapping..." error message.
+// command-line.
//
-// It uses a growarray to build the translation string since the
-// latter can be wider than the original description. The caller has to
-// free the string afterwards.
+// It uses a growarray to build the translation string since the latter can be
+// wider than the original description. The caller has to free the string
+// afterwards.
//
// Returns NULL when there is a problem.
static char_u * translate_mapping (
char_u *str,
- int expmap, // True when expanding mappings on command-line
int cpo_flags // Value of various flags present in &cpo
)
{
@@ -4373,12 +4370,8 @@ static char_u * translate_mapping (
modifiers = *++str;
c = *++str;
}
-
+
if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) {
- if (expmap) {
- ga_clear(&ga);
- return NULL;
- }
c = TO_SPECIAL(str[1], str[2]);
if (c == K_ZERO) {
// display <Nul> as ^@
@@ -4387,10 +4380,6 @@ static char_u * translate_mapping (
str += 2;
}
if (IS_SPECIAL(c) || modifiers) { // special key
- if (expmap) {
- ga_clear(&ga);
- return NULL;
- }
ga_concat(&ga, get_special_key_name(c, modifiers));
continue; /* for (str) */
}
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 85de7f26de..7d46b3b4d5 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -1130,7 +1130,7 @@ int do_search(
&& !cmd_silent && msg_silent == 0) {
char_u *trunc;
char_u off_buf[40];
- int off_len = 0;
+ size_t off_len = 0;
// Compute msg_row early.
msg_start();
@@ -1170,10 +1170,10 @@ int do_search(
len = 0; // adjusted below
} else if (msg_scrolled != 0) {
// Use all the columns.
- len = (int)(Rows - msg_row) * Columns - 1;
+ len = (Rows - msg_row) * Columns - 1;
} else {
// Use up to 'showcmd' column.
- len = (int)(Rows - msg_row - 1) * Columns + sc_col - 1;
+ len = (Rows - msg_row - 1) * Columns + sc_col - 1;
}
if (len < STRLEN(p) + off_len + SEARCH_STAT_BUF_LEN + 3) {
len = STRLEN(p) + off_len + SEARCH_STAT_BUF_LEN + 3;
@@ -1183,7 +1183,7 @@ int do_search(
len = STRLEN(p) + off_len + 3;
}
- msgbuf = xmalloc((int)len);
+ msgbuf = xmalloc(len);
{
memset(msgbuf, ' ', len);
msgbuf[0] = dirc;
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index ddd0643feb..b686d0292f 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -1673,6 +1673,25 @@ func Test_ReadWrite_Autocmds()
call delete('test.out')
endfunc
+func Test_throw_in_BufWritePre()
+ new
+ call setline(1, ['one', 'two', 'three'])
+ call assert_false(filereadable('Xthefile'))
+ augroup throwing
+ au BufWritePre X* throw 'do not write'
+ augroup END
+ try
+ w Xthefile
+ catch
+ let caught = 1
+ endtry
+ call assert_equal(1, caught)
+ call assert_false(filereadable('Xthefile'))
+
+ bwipe!
+ au! throwing
+endfunc
+
func Test_FileChangedShell_reload()
if !has('unix')
return
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index eb18284b4a..4b333e444a 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -44,6 +44,42 @@ func Test_map_completion()
call assert_equal('"map <special> <nowait>', getreg(':'))
call feedkeys(":map <silent> <sp\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map <silent> <special>', getreg(':'))
+
+ map ,f commaf
+ map ,g commaf
+ call feedkeys(":map ,\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map ,f', getreg(':'))
+ call feedkeys(":map ,\<Tab>\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map ,g', getreg(':'))
+ unmap ,f
+ unmap ,g
+
+ set cpo-=< cpo-=B cpo-=k
+ map <Left> left
+ call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <Left>', getreg(':'))
+ unmap <Left>
+
+ " set cpo+=<
+ map <Left> left
+ call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <Left>', getreg(':'))
+ unmap <Left>
+ set cpo-=<
+
+ set cpo+=B
+ map <Left> left
+ call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <Left>', getreg(':'))
+ unmap <Left>
+ set cpo-=B
+
+ " set cpo+=k
+ map <Left> left
+ call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <Left>', getreg(':'))
+ unmap <Left>
+ " set cpo-=k
endfunc
func Test_match_completion()