diff options
-rw-r--r-- | runtime/doc/eval.txt | 18 | ||||
-rw-r--r-- | runtime/doc/msgpack_rpc.txt | 5 | ||||
-rw-r--r-- | src/nvim/api/ui.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 57 | ||||
-rw-r--r-- | src/nvim/eval.h | 8 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 2 | ||||
-rw-r--r-- | src/nvim/hashtab.c | 3 | ||||
-rw-r--r-- | src/nvim/main.c | 2 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/helpers.c | 2 | ||||
-rw-r--r-- | src/nvim/rbuffer.c | 4 | ||||
-rw-r--r-- | src/nvim/screen.c | 20 | ||||
-rw-r--r-- | src/nvim/testdir/runtest.vim | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_expr.vim | 14 | ||||
-rw-r--r-- | src/nvim/testdir/test_statusline.vim | 39 | ||||
-rw-r--r-- | src/nvim/testdir/test_viml.vim | 8 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 4 | ||||
-rw-r--r-- | src/nvim/ui.c | 11 | ||||
-rw-r--r-- | src/nvim/version.c | 18 | ||||
-rw-r--r-- | src/nvim/vim.h | 8 | ||||
-rw-r--r-- | test/functional/core/exit_spec.lua | 46 | ||||
-rw-r--r-- | test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/legacy/packadd_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 3 | ||||
-rw-r--r-- | test/functional/ui/screen_basic_spec.lua | 47 |
25 files changed, 281 insertions, 66 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9c6cbd5a1a..cca53db531 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1383,6 +1383,9 @@ v:dying Normally zero. When a deadly signal is caught it's set to < Note: if another deadly signal is caught when v:dying is one, VimLeave autocommands will not be executed. + *v:exiting* *exiting-variable* +v:exiting The exit value Nvim will use. Before exiting, it is |v:null|. + *v:errmsg* *errmsg-variable* v:errmsg Last given error message. It's allowed to set this variable. Example: > @@ -1718,6 +1721,21 @@ v:swapcommand Normal mode command to be executed after a file has been example, when jumping to a tag the value is ":tag tagname\r". For ":edit +cmd file" the value is ":cmd\r". + *v:t_TYPE* *v:t_bool* *t_bool-varialble* +v:t_bool Value of Boolean type. Read-only. See: |type()| + *v:t_dict* *t_dict-varialble* +v:t_dict Value of Dictionary type. Read-only. See: |type()| + *v:t_float* *t_float-varialble* +v:t_float Value of Float type. Read-only. See: |type()| + *v:t_func* *t_func-varialble* +v:t_func Value of Funcref type. Read-only. See: |type()| + *v:t_list* *t_list-varialble* +v:t_list Value of List type. Read-only. See: |type()| + *v:t_number* *t_number-varialble* +v:t_number Value of Number type. Read-only. See: |type()| + *v:t_string* *t_string-varialble* +v:t_string Value of String type. Read-only. See: |type()| + *v:termresponse* *termresponse-variable* v:termresponse The escape sequence returned by the terminal for the |t_RV| termcap entry. It is set when Vim receives an escape sequence diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt index 757f5574d4..c074eb43ff 100644 --- a/runtime/doc/msgpack_rpc.txt +++ b/runtime/doc/msgpack_rpc.txt @@ -390,8 +390,9 @@ of update. The menu mappings changed. ["mode_change", mode] - The mode changed. Currently sent when "insert", "replace" and "normal" - modes are entered. A client could for instance change the cursor shape. + The mode changed. Currently sent when "insert", "replace", "cmdline" and + "normal" modes are entered. A client could for instance change the cursor + shape. ["popupmenu_show", items, selected, row, col] When `popupmenu_external` is set to true, nvim will not draw the diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 56b41f1eea..9178538110 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -271,6 +271,8 @@ static void remote_ui_mode_change(UI *ui, int mode) ADD(args, STRING_OBJ(cstr_to_string("insert"))); } else if (mode == REPLACE) { ADD(args, STRING_OBJ(cstr_to_string("replace"))); + } else if (mode == CMDLINE) { + ADD(args, STRING_OBJ(cstr_to_string("cmdline"))); } else { assert(mode == NORMAL); ADD(args, STRING_OBJ(cstr_to_string("normal"))); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index fc2f435508..8e8d36b442 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -387,6 +387,14 @@ static struct vimvar { VV(VV__NULL_LIST, "_null_list", VAR_LIST, VV_RO), VV(VV__NULL_DICT, "_null_dict", VAR_DICT, VV_RO), VV(VV_VIM_DID_ENTER, "vim_did_enter", VAR_NUMBER, VV_RO), + VV(VV_TYPE_NUMBER, "t_number", VAR_NUMBER, VV_RO), + VV(VV_TYPE_STRING, "t_string", VAR_NUMBER, VV_RO), + VV(VV_TYPE_FUNC, "t_func", VAR_NUMBER, VV_RO), + VV(VV_TYPE_LIST, "t_list", VAR_NUMBER, VV_RO), + VV(VV_TYPE_DICT, "t_dict", VAR_NUMBER, VV_RO), + VV(VV_TYPE_FLOAT, "t_float", VAR_NUMBER, VV_RO), + VV(VV_TYPE_BOOL, "t_bool", VAR_NUMBER, VV_RO), + VV(VV_EXITING, "exiting", VAR_NUMBER, VV_RO), }; #undef VV @@ -400,7 +408,7 @@ static struct vimvar { #define vv_dict vv_di.di_tv.vval.v_dict #define vv_tv vv_di.di_tv -static dictitem_T vimvars_var; /* variable used for v: */ +static dictitem_T vimvars_var; // variable used for v: #define vimvarht vimvardict.dv_hashtab typedef struct { @@ -562,10 +570,19 @@ void eval_init(void) set_vim_var_list(VV_ERRORS, list_alloc()); set_vim_var_nr(VV_SEARCHFORWARD, 1L); set_vim_var_nr(VV_HLSEARCH, 1L); + set_vim_var_nr(VV_COUNT1, 1); + set_vim_var_nr(VV_TYPE_NUMBER, VAR_TYPE_NUMBER); + set_vim_var_nr(VV_TYPE_STRING, VAR_TYPE_STRING); + set_vim_var_nr(VV_TYPE_FUNC, VAR_TYPE_FUNC); + set_vim_var_nr(VV_TYPE_LIST, VAR_TYPE_LIST); + set_vim_var_nr(VV_TYPE_DICT, VAR_TYPE_DICT); + set_vim_var_nr(VV_TYPE_FLOAT, VAR_TYPE_FLOAT); + set_vim_var_nr(VV_TYPE_BOOL, VAR_TYPE_BOOL); set_vim_var_special(VV_FALSE, kSpecialVarFalse); set_vim_var_special(VV_TRUE, kSpecialVarTrue); set_vim_var_special(VV_NULL, kSpecialVarNull); + set_vim_var_special(VV_EXITING, kSpecialVarNull); set_reg_var(0); // default for v:register is not 0 but '"' } @@ -2145,11 +2162,9 @@ get_lval ( if (lp->ll_tv->v_type == VAR_DICT) { if (len == -1) { - /* "[key]": get key from "var1" */ - key = get_tv_string(&var1); /* is number or string */ - if (*key == NUL) { - if (!quiet) - EMSG(_(e_emptykey)); + // "[key]": get key from "var1" + key = get_tv_string_chk(&var1); // is number or string + if (key == NULL) { clear_tv(&var1); return NULL; } @@ -4600,10 +4615,8 @@ eval_index ( dictitem_T *item; if (len == -1) { - key = get_tv_string(&var1); - if (*key == NUL) { - if (verbose) - EMSG(_(e_emptykey)); + key = get_tv_string_chk(&var1); + if (key == NULL) { clear_tv(&var1); return FAIL; } @@ -6587,10 +6600,8 @@ static int get_dict_tv(char_u **arg, typval_T *rettv, int evaluate) } if (evaluate) { key = get_tv_string_buf_chk(&tvkey, buf); - if (key == NULL || *key == NUL) { - /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */ - if (key != NULL) - EMSG(_(e_emptykey)); + if (key == NULL) { + // "key" is NULL when get_tv_string_buf_chk() gave an errmsg clear_tv(&tvkey); goto failret; } @@ -16800,17 +16811,17 @@ static void f_type(typval_T *argvars, typval_T *rettv, FunPtr fptr) int n = -1; switch (argvars[0].v_type) { - case VAR_NUMBER: n = 0; break; - case VAR_STRING: n = 1; break; - case VAR_FUNC: n = 2; break; - case VAR_LIST: n = 3; break; - case VAR_DICT: n = 4; break; - case VAR_FLOAT: n = 5; break; + case VAR_NUMBER: n = VAR_TYPE_NUMBER; break; + case VAR_STRING: n = VAR_TYPE_STRING; break; + case VAR_FUNC: n = VAR_TYPE_FUNC; break; + case VAR_LIST: n = VAR_TYPE_LIST; break; + case VAR_DICT: n = VAR_TYPE_DICT; break; + case VAR_FLOAT: n = VAR_TYPE_FLOAT; break; case VAR_SPECIAL: { switch (argvars[0].vval.v_special) { case kSpecialVarTrue: case kSpecialVarFalse: { - n = 6; + n = VAR_TYPE_BOOL; break; } case kSpecialVarNull: { @@ -17754,6 +17765,8 @@ void set_vcount(long count, long count1, int set_prevcount) /// @param[in] val Value to set to. void set_vim_var_nr(const VimVarIndex idx, const varnumber_T val) { + clear_tv(&vimvars[idx].vv_tv); + vimvars[idx].vv_type = VAR_NUMBER; vimvars[idx].vv_nr = val; } @@ -17763,6 +17776,8 @@ void set_vim_var_nr(const VimVarIndex idx, const varnumber_T val) /// @param[in] val Value to set to. void set_vim_var_special(const VimVarIndex idx, const SpecialVarValue val) { + clear_tv(&vimvars[idx].vv_tv); + vimvars[idx].vv_type = VAR_SPECIAL; vimvars[idx].vv_special = val; } diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 1061840816..630e309442 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -127,6 +127,14 @@ typedef enum { VV__NULL_LIST, // List with NULL value. For test purposes only. VV__NULL_DICT, // Dictionary with NULL value. For test purposes only. VV_VIM_DID_ENTER, + VV_TYPE_NUMBER, + VV_TYPE_STRING, + VV_TYPE_FUNC, + VV_TYPE_LIST, + VV_TYPE_DICT, + VV_TYPE_FLOAT, + VV_TYPE_BOOL, + VV_EXITING, } VimVarIndex; /// All recognized msgpack types diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index f68663c60c..3b92b3734a 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2552,7 +2552,7 @@ static void add_pack_plugin(char_u *fname, void *cookie) } if (cookie != &APP_ADD_DIR) { - static const char *plugpat = "%s/plugin/*.vim"; // NOLINT + static const char *plugpat = "%s/plugin/**/*.vim"; // NOLINT static const char *ftpat = "%s/ftdetect/*.vim"; // NOLINT size_t len = STRLEN(ffname) + STRLEN(ftpat); diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index 7d4ae61fc4..fa4077f22f 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -368,8 +368,7 @@ hash_T hash_hash(char_u *key) hash_T hash = *key; if (hash == 0) { - // Empty keys are not allowed, but we don't want to crash if we get one. - return (hash_T) 0; + return (hash_T)0; } // A simplistic algorithm that appears to do very well. diff --git a/src/nvim/main.c b/src/nvim/main.c index 1bd622bdba..9b9976ac0a 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -557,6 +557,8 @@ void getout(int exitval) if (exmode_active) exitval += ex_exitval; + set_vim_var_nr(VV_EXITING, exitval); + /* Position the cursor on the last screen line, below all the text */ ui_cursor_goto((int)Rows - 1, 0); diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index b0cfe2d6cd..5137b375f0 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -125,7 +125,7 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg) dest = conv(((String) { \ .size = obj->via.attr.size, \ .data = (obj->via.attr.ptr == NULL || obj->via.attr.size == 0 \ - ? NULL \ + ? xmemdupz("", 0) \ : xmemdupz(obj->via.attr.ptr, obj->via.attr.size)), \ })); \ break; \ diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index a2cc432eca..111af0d0fb 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -18,7 +18,7 @@ RBuffer *rbuffer_new(size_t capacity) capacity = 0x10000; } - RBuffer *rv = xmalloc(sizeof(RBuffer) + capacity); + RBuffer *rv = xcalloc(1, sizeof(RBuffer) + capacity); rv->full_cb = rv->nonfull_cb = NULL; rv->data = NULL; rv->size = 0; @@ -78,7 +78,7 @@ void rbuffer_reset(RBuffer *buf) FUNC_ATTR_NONNULL_ALL size_t temp_size; if ((temp_size = rbuffer_size(buf))) { if (buf->temp == NULL) { - buf->temp = xmalloc(rbuffer_capacity(buf)); + buf->temp = xcalloc(1, rbuffer_capacity(buf)); } rbuffer_read(buf, buf->temp, buf->size); } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index d55517c0f7..9075f94a20 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4939,8 +4939,8 @@ void win_redr_status(win_T *wp) */ static void redraw_custom_statusline(win_T *wp) { - static int entered = FALSE; - int save_called_emsg = called_emsg; + static int entered = false; + int saved_did_emsg = did_emsg; /* When called recursively return. This can happen when the statusline * contains an expression that triggers a redraw. */ @@ -4948,18 +4948,18 @@ static void redraw_custom_statusline(win_T *wp) return; entered = TRUE; - called_emsg = FALSE; - win_redr_custom(wp, FALSE); - if (called_emsg) { - /* When there is an error disable the statusline, otherwise the - * display is messed up with errors and a redraw triggers the problem - * again and again. */ + did_emsg = false; + win_redr_custom(wp, false); + if (did_emsg) { + // When there is an error disable the statusline, otherwise the + // display is messed up with errors and a redraw triggers the problem + // again and again. set_string_option_direct((char_u *)"statusline", -1, (char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL ? OPT_LOCAL : OPT_GLOBAL), SID_ERROR); } - called_emsg |= save_called_emsg; - entered = FALSE; + did_emsg |= saved_did_emsg; + entered = false; } /* diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 34b6b846ca..d1857565a4 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -59,6 +59,9 @@ lang mess C " Always use forward slashes. set shellslash +" Make sure $HOME does not get read or written. +let $HOME = '/does/not/exist' + function RunTheTest(test) echo 'Executing ' . a:test if exists("*SetUp") @@ -131,6 +134,9 @@ for s:test in sort(s:tests) endfor +" Don't write viminfo on exit. +set viminfo= + if s:fail == 0 " Success, create the .res file so that make knows it's done. exe 'split ' . fnamemodify(g:testname, ':r') . '.res' diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 4408dfc734..d460134fb9 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -12,6 +12,7 @@ source test_menu.vim source test_options.vim source test_popup.vim source test_regexp_utf8.vim +source test_statusline.vim source test_syn_attr.vim source test_tabline.vim source test_tabpage.vim diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index 83b5e66fe0..66a10b05e1 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -38,3 +38,17 @@ func Test_strcharpart() call assert_equal('a', strcharpart('axb', -1, 2)) endfunc + +func Test_dict() + let d = {'': 'empty', 'a': 'a', 0: 'zero'} + call assert_equal('empty', d['']) + call assert_equal('a', d['a']) + call assert_equal('zero', d[0]) + call assert_true(has_key(d, '')) + call assert_true(has_key(d, 'a')) + + let d[''] = 'none' + let d['a'] = 'aaa' + call assert_equal('none', d['']) + call assert_equal('aaa', d['a']) +endfunc diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim new file mode 100644 index 0000000000..82898df92d --- /dev/null +++ b/src/nvim/testdir/test_statusline.vim @@ -0,0 +1,39 @@ +function! StatuslineWithCaughtError() + let s:func_in_statusline_called = 1 + try + call eval('unknown expression') + catch + endtry + return '' +endfunction + +function! StatuslineWithError() + let s:func_in_statusline_called = 1 + call eval('unknown expression') + return '' +endfunction + +function! Test_caught_error_in_statusline() + let s:func_in_statusline_called = 0 + set laststatus=2 + let statusline = '%{StatuslineWithCaughtError()}' + let &statusline = statusline + redrawstatus + call assert_true(s:func_in_statusline_called) + call assert_equal(statusline, &statusline) + set statusline= +endfunction + +function! Test_statusline_will_be_disabled_with_error() + let s:func_in_statusline_called = 0 + set laststatus=2 + let statusline = '%{StatuslineWithError()}' + try + let &statusline = statusline + redrawstatus + catch + endtry + call assert_true(s:func_in_statusline_called) + call assert_equal('', &statusline) + set statusline= +endfunction diff --git a/src/nvim/testdir/test_viml.vim b/src/nvim/testdir/test_viml.vim index c39c5e6b28..a11d62f5cf 100644 --- a/src/nvim/testdir/test_viml.vim +++ b/src/nvim/testdir/test_viml.vim @@ -949,6 +949,14 @@ func Test_type() call assert_equal(6, type(v:false)) call assert_equal(6, type(v:true)) call assert_equal(7, type(v:null)) + call assert_equal(v:t_number, type(0)) + call assert_equal(v:t_string, type("")) + call assert_equal(v:t_func, type(function("tr"))) + call assert_equal(v:t_list, type([])) + call assert_equal(v:t_dict, type({})) + call assert_equal(v:t_float, type(0.0)) + call assert_equal(v:t_bool, type(v:false)) + call assert_equal(v:t_bool, type(v:true)) endfunc "------------------------------------------------------------------------------- diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 5e30517c5a..2171e580ba 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -461,6 +461,10 @@ static void tui_mode_change(UI *ui, int mode) if (data->showing_mode != INSERT) { unibi_out(ui, data->unibi_ext.set_cursor_shape_bar); } + } else if (mode == CMDLINE) { + if (data->showing_mode != CMDLINE) { + unibi_out(ui, data->unibi_ext.set_cursor_shape_bar); + } } else if (mode == REPLACE) { if (data->showing_mode != REPLACE) { unibi_out(ui, data->unibi_ext.set_cursor_shape_ul); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 549ed8aa7d..ea0bccb1cd 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -532,13 +532,16 @@ static void ui_mode_change(void) if (!full_screen) { return; } - /* Get a simple UI mode out of State. */ - if ((State & REPLACE) == REPLACE) + // Get a simple UI mode out of State. + if ((State & REPLACE) == REPLACE) { mode = REPLACE; - else if (State & INSERT) + } else if (State & INSERT) { mode = INSERT; - else + } else if (State & CMDLINE) { + mode = CMDLINE; + } else { mode = NORMAL; + } UI_CALL(mode_change, mode); conceal_check_cursur_line(); } diff --git a/src/nvim/version.c b/src/nvim/version.c index e6eb4c2472..5b0c967ee2 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -131,7 +131,7 @@ static int included_patches[] = { // 2314, // 2313, 2312, - // 2311, + // 2311 NA // 2310 NA 2309, // 2308 NA @@ -371,7 +371,7 @@ static int included_patches[] = { // 2074, // 2073, // 2072, - // 2071, + 2071, // 2070 NA // 2069, // 2068, @@ -435,7 +435,7 @@ static int included_patches[] = { // 2010, // 2009, // 2008, - // 2007, + 2007, // 2006, // 2005, // 2004 NA @@ -733,19 +733,19 @@ static int included_patches[] = { 1714, // 1713 NA 1712, - // 1711, - // 1710, + 1711, + // 1710 NA // 1709 NA // 1708, - // 1707, + 1707, // 1706 NA // 1705 NA 1704, 1703, // 1702, - // 1701, + 1701, 1700, - // 1699, + 1699, // 1698 NA 1697, 1696, @@ -758,7 +758,7 @@ static int included_patches[] = { // 1689 NA // 1688 NA // 1687 NA - // 1686, + 1686, // 1685, // 1684 NA // 1683 NA diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 32eba55c18..8271abda8d 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -123,6 +123,14 @@ Error: configure did not run properly.Check auto/config.log. #define FAIL 0 #define NOTDONE 2 /* not OK or FAIL but skipped */ +// Type values for type(). +#define VAR_TYPE_NUMBER 0 +#define VAR_TYPE_STRING 1 +#define VAR_TYPE_FUNC 2 +#define VAR_TYPE_LIST 3 +#define VAR_TYPE_DICT 4 +#define VAR_TYPE_FLOAT 5 +#define VAR_TYPE_BOOL 6 /* * values for xp_context when doing command line completion diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua new file mode 100644 index 0000000000..3fb39f3e78 --- /dev/null +++ b/test/functional/core/exit_spec.lua @@ -0,0 +1,46 @@ +local helpers = require('test.functional.helpers')(after_each) + +local command = helpers.command +local eval = helpers.eval +local eq, neq = helpers.eq, helpers.neq +local run = helpers.run + +describe('v:exiting', function() + local cid + + before_each(function() + helpers.clear() + cid = helpers.nvim('get_api_info')[1] + end) + + it('defaults to v:null', function() + eq(1, eval('v:exiting is v:null')) + end) + + it('is 0 on normal exit', function() + local function on_setup() + command('autocmd VimLeavePre * call rpcrequest('..cid..', "")') + command('autocmd VimLeave * call rpcrequest('..cid..', "")') + command('quit') + end + local function on_request() + eq(0, eval('v:exiting')) + return '' + end + run(on_request, nil, on_setup) + end) + + it('is non-zero after :cquit', function() + local function on_setup() + command('autocmd VimLeavePre * call rpcrequest('..cid..', "")') + command('autocmd VimLeave * call rpcrequest('..cid..', "")') + command('cquit') + end + local function on_request() + neq(0, eval('v:exiting')) + return '' + end + run(on_request, nil, on_setup) + end) + +end) diff --git a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua index 4189e8a33a..c6883e4902 100644 --- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua +++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua @@ -28,8 +28,6 @@ local function run_test_with_regexpengine(regexpengine) e y f z g a啷bb - h AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐẔ - i aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑẕ j 0123❤x k combinations l ä ö ü ᾱ̆́]]) @@ -68,14 +66,6 @@ local function run_test_with_regexpengine(regexpengine) feed([[/\%U12345678<cr>x]]) feed([[/[\U1234abcd\u1234\uabcd]<cr>x]]) feed([[/\%d21879b<cr>x]]) - feed('/ [[=A=]]* [[=B=]]* [[=C=]]* [[=D=]]* [[=E=]]* [[=F=]]* ' .. - '[[=G=]]* [[=H=]]* [[=I=]]* [[=J=]]* [[=K=]]* [[=L=]]* [[=M=]]* ' .. - '[[=N=]]* [[=O=]]* [[=P=]]* [[=Q=]]* [[=R=]]* [[=S=]]* [[=T=]]* ' .. - '[[=U=]]* [[=V=]]* [[=W=]]* [[=X=]]* [[=Y=]]* [[=Z=]]*/e<cr>x') - feed('/ [[=a=]]* [[=b=]]* [[=c=]]* [[=d=]]* [[=e=]]* [[=f=]]* ' .. - '[[=g=]]* [[=h=]]* [[=i=]]* [[=j=]]* [[=k=]]* [[=l=]]* [[=m=]]* ' .. - '[[=n=]]* [[=o=]]* [[=p=]]* [[=q=]]* [[=r=]]* [[=s=]]* [[=t=]]* ' .. - '[[=u=]]* [[=v=]]* [[=w=]]* [[=x=]]* [[=y=]]* [[=z=]]*/e<cr>x') -- Line j. Test backwards search from a multi-byte character. feed('/x<cr>x') @@ -125,8 +115,6 @@ local function run_test_with_regexpengine(regexpengine) e y f z g abb - h AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐ - i aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑ j 012❤ k œ̄ṣ́m̥̄ᾱ̆́ l ä ö ü ᾱ̆́ diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 68bdbf5257..2d851819e3 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -27,7 +27,7 @@ describe('packadd', function() endfunc func Test_packadd() - call mkdir(s:plugdir . '/plugin', 'p') + call mkdir(s:plugdir . '/plugin/also', 'p') call mkdir(s:plugdir . '/ftdetect', 'p') call mkdir(s:plugdir . '/after', 'p') set rtp& @@ -38,6 +38,10 @@ describe('packadd', function() call setline(1, 'let g:plugin_works = 42') wq + exe 'split ' . s:plugdir . '/plugin/also/loaded.vim' + call setline(1, 'let g:plugin_also_works = 77') + wq + exe 'split ' . s:plugdir . '/ftdetect/test.vim' call setline(1, 'let g:ftdetect_works = 17') wq @@ -45,6 +49,7 @@ describe('packadd', function() packadd mytest call assert_true(42, g:plugin_works) + call assert_equal(77, g:plugin_also_works) call assert_true(17, g:ftdetect_works) call assert_true(len(&rtp) > len(rtp)) call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 6c1a1788ce..ebe8af35eb 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -374,7 +374,8 @@ function Screen:_handle_mouse_off() end function Screen:_handle_mode_change(mode) - assert(mode == 'insert' or mode == 'replace' or mode == 'normal') + assert(mode == 'insert' or mode == 'replace' + or mode == 'normal' or mode == 'cmdline') self.mode = mode end diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 593b6dd763..d03f98c26f 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -642,5 +642,52 @@ describe('Screen', function() eq("normal", screen.mode) end) end) + + it('works in cmdline mode', function() + feed(':') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + :^ | + ]],nil,nil,function () + eq("cmdline", screen.mode) + end) + + feed('<esc>/') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + /^ | + ]],nil,nil,function () + eq("cmdline", screen.mode) + end) + + + feed('<esc>?') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + ?^ | + ]],nil,nil,function () + eq("cmdline", screen.mode) + end) + + feed('<esc>') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]],nil,nil,function () + eq("normal", screen.mode) + end) + end) end) end) |