aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds.c5
-rw-r--r--src/nvim/ex_eval.c7
-rw-r--r--src/nvim/highlight_group.c2
-rw-r--r--src/nvim/regexp.c19
-rw-r--r--src/nvim/testdir/test_sort.vim2
5 files changed, 25 insertions, 10 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index e79a587000..89e6d47950 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -504,9 +504,8 @@ void ex_sort(exarg_T *eap)
eap->nextcmd = check_nextcmd(p);
break;
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
- s = skip_regexp(p + 1, *p, true);
- if (*s != *p) {
- emsg(_(e_invalpat));
+ s = skip_regexp_err(p + 1, *p, true);
+ if (s == NULL) {
goto sortend;
}
*s = NUL;
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 761c0770b6..8c2ac895cb 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -900,12 +900,12 @@ void ex_else(exarg_T *eap)
if (eap->cmdidx == CMD_elseif) {
bool error;
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
+
// When throwing error exceptions, we want to throw always the first
// of several errors in a row. This is what actually happens when
// a conditional error was detected above and there is another failure
// when parsing the expression. Since the skip flag is set in this
// case, the parsing error will be ignored by emsg().
-
if (!skip && !error) {
if (result) {
cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE | CSF_TRUE;
@@ -1296,7 +1296,10 @@ void ex_catch(exarg_T *eap)
eap->nextcmd = find_nextcmd(eap->arg);
} else {
pat = eap->arg + 1;
- end = skip_regexp(pat, *eap->arg, true);
+ end = skip_regexp_err(pat, *eap->arg, true);
+ if (end == NULL) {
+ give_up = true;
+ }
}
if (!give_up) {
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 4c253480be..9a09118939 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -851,7 +851,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
bool did_highlight_changed = false;
// If no argument, list current highlighting.
- if (ends_excmd((uint8_t)(*line))) {
+ if (!init && ends_excmd((uint8_t)(*line))) {
for (int i = 1; i <= highlight_ga.ga_len && !got_int; i++) {
// TODO(brammool): only call when the group has attributes set
highlight_list_one(i);
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 4ae7fc7578..68ffc70457 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -481,12 +481,25 @@ static char_u *skip_anyof(char *p)
}
/// Skip past regular expression.
-/// Stop at end of "startp" or where "dirc" is found ('/', '?', etc).
+/// Stop at end of "startp" or where "delim" is found ('/', '?', etc).
/// Take care of characters with a backslash in front of it.
/// Skip strings inside [ and ].
-char *skip_regexp(char *startp, int dirc, int magic)
+char *skip_regexp(char *startp, int delim, int magic)
{
- return skip_regexp_ex(startp, dirc, magic, NULL, NULL);
+ return skip_regexp_ex(startp, delim, magic, NULL, NULL);
+}
+
+/// Call skip_regexp() and when the delimiter does not match give an error and
+/// return NULL.
+char *skip_regexp_err(char *startp, int delim, int magic)
+{
+ char *p = skip_regexp(startp, delim, magic);
+
+ if (*p != delim) {
+ semsg(_("E654: missing delimiter after search pattern: %s"), startp);
+ return NULL;
+ }
+ return p;
}
/// skip_regexp() with extra arguments:
diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim
index c3e7788164..f9cbcbb55f 100644
--- a/src/nvim/testdir/test_sort.vim
+++ b/src/nvim/testdir/test_sort.vim
@@ -1360,7 +1360,7 @@ func Test_sort_cmd()
call setline(1, ['line1', 'line2'])
call assert_fails('sort no', 'E474:')
call assert_fails('sort c', 'E475:')
- call assert_fails('sort #pat%', 'E682:')
+ call assert_fails('sort #pat%', 'E654:')
enew!
endfunc