summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-02 18:55:57 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-02 18:55:57 +0200
commit5b8cabfef7c3707f3e53e13844d90e5a217e1e84 (patch)
tree419de5d628c379b090538a811bb6d33270dcdd85
parentdcf29ac87f4d7a62c503ba6de0d92c7779446bf2 (diff)
patch 8.2.2694: when 'matchpairs' is empty every character beepsv8.2.2694
Problem: When 'matchpairs' is empty every character beeps. (Marco Hinz) Solution: Bail out when no character in 'matchpairs' was found. (closes #8053) Add assert_nobeep().
-rw-r--r--runtime/doc/eval.txt1
-rw-r--r--runtime/doc/testing.txt11
-rw-r--r--src/evalfunc.c2
-rw-r--r--src/proto/testing.pro1
-rw-r--r--src/search.c2
-rw-r--r--src/testdir/test_textformat.vim8
-rw-r--r--src/testing.c20
-rw-r--r--src/version.c2
8 files changed, 42 insertions, 5 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 57ab47e0ce..97c968c748 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2440,6 +2440,7 @@ assert_inrange({lower}, {upper}, {actual} [, {msg}])
Number assert {actual} is inside the range
assert_match({pat}, {text} [, {msg}])
Number assert {pat} matches {text}
+assert_nobeep({cmd}) Number assert {cmd} does not cause a beep
assert_notequal({exp}, {act} [, {msg}])
Number assert {exp} is not equal {act}
assert_notmatch({pat}, {text} [, {msg}])
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index 4e4cff0c27..5d85358d71 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -243,7 +243,8 @@ test_srand_seed([seed]) *test_srand_seed()*
assert_beeps({cmd}) *assert_beeps()*
Run {cmd} and add an error message to |v:errors| if it does
NOT produce a beep or visual bell.
- Also see |assert_fails()| and |assert-return|.
+ Also see |assert_fails()|, |assert_nobeep()| and
+ |assert-return|.
Can also be used as a |method|: >
GetCmd()->assert_beeps()
@@ -377,6 +378,14 @@ assert_match({pattern}, {actual} [, {msg}])
Can also be used as a |method|: >
getFile()->assert_match('foo.*')
<
+assert_nobeep({cmd}) *assert_nobeep()*
+ Run {cmd} and add an error message to |v:errors| if it
+ produces a beep or visual bell.
+ Also see |assert_beeps()|.
+
+ Can also be used as a |method|: >
+ GetCmd()->assert_nobeep()
+<
*assert_notequal()*
assert_notequal({expected}, {actual} [, {msg}])
The opposite of `assert_equal()`: add an error message to
diff --git a/src/evalfunc.c b/src/evalfunc.c
index f83559dbbe..5383d098f4 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -739,6 +739,8 @@ static funcentry_T global_functions[] =
ret_number_bool, f_assert_inrange},
{"assert_match", 2, 3, FEARG_2, NULL,
ret_number_bool, f_assert_match},
+ {"assert_nobeep", 1, 2, FEARG_1, NULL,
+ ret_number_bool, f_assert_nobeep},
{"assert_notequal", 2, 3, FEARG_2, NULL,
ret_number_bool, f_assert_notequal},
{"assert_notmatch", 2, 3, FEARG_2, NULL,
diff --git a/src/proto/testing.pro b/src/proto/testing.pro
index b812c2a270..d229030cb5 100644
--- a/src/proto/testing.pro
+++ b/src/proto/testing.pro
@@ -1,5 +1,6 @@
/* testing.c */
void f_assert_beeps(typval_T *argvars, typval_T *rettv);
+void f_assert_nobeep(typval_T *argvars, typval_T *rettv);
void f_assert_equal(typval_T *argvars, typval_T *rettv);
void f_assert_equalfile(typval_T *argvars, typval_T *rettv);
void f_assert_notequal(typval_T *argvars, typval_T *rettv);
diff --git a/src/search.c b/src/search.c
index d8c21f43c7..37ccc37e9c 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2817,6 +2817,8 @@ showmatch(
if (*p == NUL)
return;
}
+ if (*p == NUL)
+ return;
if ((lpos = findmatch(NULL, NUL)) == NULL) // no match, so beep
vim_beep(BO_MATCH);
diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim
index 32ff3cc70b..0dc28c7307 100644
--- a/src/testdir/test_textformat.vim
+++ b/src/testdir/test_textformat.vim
@@ -858,6 +858,14 @@ func Test_mps_latin1()
close!
endfunc
+func Test_empty_matchpairs()
+ split
+ set matchpairs= showmatch
+ call assert_nobeep('call feedkeys("ax\tx\t\<Esc>", "xt")')
+ set matchpairs& noshowmatch
+ bwipe!
+endfunc
+
func Test_mps_error()
let encoding_save = &encoding
diff --git a/src/testing.c b/src/testing.c
index df19b9eb49..740923735c 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -338,7 +338,7 @@ assert_append_cmd_or_arg(garray_T *gap, typval_T *argvars, char_u *cmd)
}
static int
-assert_beeps(typval_T *argvars)
+assert_beeps(typval_T *argvars, int no_beep)
{
char_u *cmd = tv_get_string_chk(&argvars[0]);
garray_T ga;
@@ -348,10 +348,13 @@ assert_beeps(typval_T *argvars)
suppress_errthrow = TRUE;
emsg_silent = FALSE;
do_cmdline_cmd(cmd);
- if (!called_vim_beep)
+ if (no_beep ? called_vim_beep : !called_vim_beep)
{
prepare_assert_error(&ga);
- ga_concat(&ga, (char_u *)"command did not beep: ");
+ if (no_beep)
+ ga_concat(&ga, (char_u *)"command did beep: ");
+ else
+ ga_concat(&ga, (char_u *)"command did not beep: ");
ga_concat(&ga, cmd);
assert_error(&ga);
ga_clear(&ga);
@@ -369,7 +372,16 @@ assert_beeps(typval_T *argvars)
void
f_assert_beeps(typval_T *argvars, typval_T *rettv)
{
- rettv->vval.v_number = assert_beeps(argvars);
+ rettv->vval.v_number = assert_beeps(argvars, FALSE);
+}
+
+/*
+ * "assert_nobeep(cmd [, error])" function
+ */
+ void
+f_assert_nobeep(typval_T *argvars, typval_T *rettv)
+{
+ rettv->vval.v_number = assert_beeps(argvars, TRUE);
}
/*
diff --git a/src/version.c b/src/version.c
index 760a0f48eb..661a93cd8d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2694,
+/**/
2693,
/**/
2692,