diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2018-06-07 03:59:45 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-06-07 09:59:45 +0200 |
commit | 7f6c1d256f4c9f78d71b4a605095d3dea0ea7abb (patch) | |
tree | 3611a8a45d2d1d357f1ca25ec9282437a5c38348 /src | |
parent | 36ac80d5dd58e726a89c7108051e29de500a2f77 (diff) | |
download | rneovim-7f6c1d256f4c9f78d71b4a605095d3dea0ea7abb.tar.gz rneovim-7f6c1d256f4c9f78d71b4a605095d3dea0ea7abb.tar.bz2 rneovim-7f6c1d256f4c9f78d71b4a605095d3dea0ea7abb.zip |
vim-patch:8.0.0254: error message of assert functions (#8488)
Problem: When using an assert function one can either specify a message or
get a message about what failed, not both.
Solution: Concatenate the error with the message.
https://github.com/vim/vim/commit/c7b831ca154537505f5a22d01335a86b2e9cb023
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ffea88aa83..69b16f2113 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6742,36 +6742,39 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *tofree; if (opt_msg_tv->v_type != VAR_UNKNOWN) { - tofree = (char_u *) encode_tv2string(opt_msg_tv, NULL); + tofree = (char_u *)encode_tv2echo(opt_msg_tv, NULL); ga_concat(gap, tofree); xfree(tofree); + ga_concat(gap, (char_u *)": "); + } + + if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) { + ga_concat(gap, (char_u *)"Pattern "); + } else if (atype == ASSERT_NOTEQUAL) { + ga_concat(gap, (char_u *)"Expected not equal to "); } else { - if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) { - ga_concat(gap, (char_u *)"Pattern "); - } else if (atype == ASSERT_NOTEQUAL) { - ga_concat(gap, (char_u *)"Expected not equal to "); - } else { - ga_concat(gap, (char_u *)"Expected "); - } - if (exp_str == NULL) { - tofree = (char_u *)encode_tv2string(exp_tv, NULL); - ga_concat_esc(gap, tofree); - xfree(tofree); + ga_concat(gap, (char_u *)"Expected "); + } + + if (exp_str == NULL) { + tofree = (char_u *)encode_tv2string(exp_tv, NULL); + ga_concat_esc(gap, tofree); + xfree(tofree); + } else { + ga_concat_esc(gap, exp_str); + } + + if (atype != ASSERT_NOTEQUAL) { + if (atype == ASSERT_MATCH) { + ga_concat(gap, (char_u *)" does not match "); + } else if (atype == ASSERT_NOTMATCH) { + ga_concat(gap, (char_u *)" does match "); } else { - ga_concat_esc(gap, exp_str); - } - if (atype != ASSERT_NOTEQUAL) { - if (atype == ASSERT_MATCH) { - ga_concat(gap, (char_u *)" does not match "); - } else if (atype == ASSERT_NOTMATCH) { - ga_concat(gap, (char_u *)" does match "); - } else { - ga_concat(gap, (char_u *)" but got "); - } - tofree = (char_u *)encode_tv2string(got_tv, NULL); - ga_concat_esc(gap, tofree); - xfree(tofree); + ga_concat(gap, (char_u *)" but got "); } + tofree = (char_u *)encode_tv2string(got_tv, NULL); + ga_concat_esc(gap, tofree); + xfree(tofree); } } |