diff options
-rw-r--r-- | runtime/autoload/remote/host.vim | 31 | ||||
-rw-r--r-- | src/nvim/eval.c | 3 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 1 | ||||
-rw-r--r-- | src/nvim/version.c | 2 | ||||
-rw-r--r-- | test/functional/ex_cmds/drop_spec.lua | 80 | ||||
-rw-r--r-- | test/functional/legacy/assert_spec.lua | 30 |
6 files changed, 133 insertions, 14 deletions
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim index a63c6a923b..4ec2eeb5b7 100644 --- a/runtime/autoload/remote/host.vim +++ b/runtime/autoload/remote/host.vim @@ -1,7 +1,5 @@ let s:hosts = {} let s:plugin_patterns = {} -let s:remote_plugins_manifest = fnamemodify(expand($MYVIMRC, 1), ':h') - \.'/.'.fnamemodify($MYVIMRC, ':t').'-rplugin~' let s:plugins_for_host = {} @@ -120,9 +118,18 @@ function! remote#host#RegisterPlugin(host, path, specs) abort endfunction +function! s:GetManifest() abort + let prefix = exists('$MYVIMRC') + \ ? $MYVIMRC + \ : matchstr(get(split(capture('scriptnames'), '\n'), 0, ''), '\f\+$') + return fnamemodify(expand(prefix, 1), ':h') + \.'/.'.fnamemodify(prefix, ':t').'-rplugin~' +endfunction + + function! remote#host#LoadRemotePlugins() abort - if filereadable(s:remote_plugins_manifest) - exe 'source '.s:remote_plugins_manifest + if filereadable(s:GetManifest()) + exe 'source '.s:GetManifest() endif endfunction @@ -194,9 +201,9 @@ function! remote#host#UpdateRemotePlugins() abort endtry endif endfor - call writefile(commands, s:remote_plugins_manifest) + call writefile(commands, s:GetManifest()) echomsg printf('remote/host: generated the manifest file in "%s"', - \ s:remote_plugins_manifest) + \ s:GetManifest()) endfunction @@ -210,12 +217,12 @@ endfunction function! remote#host#LoadErrorForHost(host, log) abort return 'Failed to load '. a:host . ' host. '. - \ 'You can try to see what happened '. - \ 'by starting Neovim with the environment variable '. - \ a:log . ' set to a file and opening the generated '. - \ 'log file. Also, the host stderr will be available '. - \ 'in Neovim log, so it may contain useful information. '. - \ 'See also ~/.nvimlog.' + \ 'You can try to see what happened '. + \ 'by starting Neovim with the environment variable '. + \ a:log . ' set to a file and opening the generated '. + \ 'log file. Also, the host stderr will be available '. + \ 'in Neovim log, so it may contain useful information. '. + \ 'See also ~/.nvimlog.' endfunction diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 06ed3407dd..9a86c5765c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7668,7 +7668,8 @@ static void f_assert_exception(typval_T *argvars, typval_T *rettv) ga_concat(&ga, (char_u *)"v:exception is not set"); assert_error(&ga); ga_clear(&ga); - } else if (strstr((char *)vimvars[VV_EXCEPTION].vv_str, error) == NULL) { + } else if (error != NULL + && strstr((char *)vimvars[VV_EXCEPTION].vv_str, error) == NULL) { prepare_assert_error(&ga); fill_assert_error(&ga, &argvars[1], NULL, &argvars[0], &vimvars[VV_EXCEPTION].vv_tv); diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index e7f51326c4..40074f726c 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3533,5 +3533,6 @@ void ex_drop(exarg_T *eap) } else { eap->cmdidx = CMD_first; } + ex_rewind(eap); } } diff --git a/src/nvim/version.c b/src/nvim/version.c index 864aa8d30c..b2c6b332d1 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -558,7 +558,7 @@ static int included_patches[] = { // 1139 NA // 1138 NA 1137, - // 1136, + 1136, // 1135 NA // 1134 NA // 1133 NA diff --git a/test/functional/ex_cmds/drop_spec.lua b/test/functional/ex_cmds/drop_spec.lua new file mode 100644 index 0000000000..16b194dd7d --- /dev/null +++ b/test/functional/ex_cmds/drop_spec.lua @@ -0,0 +1,80 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute + +describe(":drop", function() + local screen + + before_each(function() + clear() + screen = Screen.new(35, 10) + screen:attach() + screen:set_default_attr_ignore({{bold=true, foreground=Screen.colors.Blue}}) + screen:set_default_attr_ids({ + [1] = {bold = true, reverse = true}, + [2] = {reverse = true}, + [3] = {bold = true}, + }) + execute("set laststatus=2") + end) + + after_each(function() + screen:detach() + end) + + it("works like :e when called with only one window open", function() + execute("drop tmp1.vim") + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + {1:tmp1.vim }| + "tmp1.vim" [New File] | + ]]) + end) + + it("switches to an open window showing the buffer", function() + execute("edit tmp1") + execute("vsplit") + execute("edit tmp2") + execute("drop tmp1") + screen:expect([[ + {2:|}^ | + ~ {2:|}~ | + ~ {2:|}~ | + ~ {2:|}~ | + ~ {2:|}~ | + ~ {2:|}~ | + ~ {2:|}~ | + ~ {2:|}~ | + {2:tmp2 }{1:tmp1 }| + :drop tmp1 | + ]]) + end) + + it("splits off a new window when a buffer can't be abandoned", function() + execute("edit tmp1") + execute("vsplit") + execute("edit tmp2") + feed("iABC<esc>") + execute("drop tmp3") + screen:expect([[ + ^ {2:|} | + ~ {2:|}~ | + ~ {2:|}~ | + ~ {2:|}~ | + {1:tmp3 }{2:|}~ | + ABC {2:|}~ | + ~ {2:|}~ | + ~ {2:|}~ | + {2:tmp2 [+] tmp1 }| + "tmp3" [New File] | + ]]) + end) + +end) diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua index cfa368c361..8da6ee45d7 100644 --- a/test/functional/legacy/assert_spec.lua +++ b/test/functional/legacy/assert_spec.lua @@ -172,4 +172,34 @@ describe('assert function:', function() expected_errors({'command did not fail: call empty("")'}) end) end) + + -- assert_exception({cmd}, [, {error}]) + describe('assert_exception()', function() + it('should assert thrown exceptions properly', function() + source([[ + try + nocommand + catch + call assert_exception('E492') + endtry + ]]) + expected_empty() + end) + + it('should work properly when nested', function() + source([[ + try + nocommand + catch + try + " illegal argument, get NULL for error + call assert_exception([]) + catch + call assert_exception('E730') + endtry + endtry + ]]) + expected_empty() + end) + end) end) |