aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraichoo <raichoo@googlemail.com>2017-03-11 11:53:56 +0100
committerraichoo <raichoo@googlemail.com>2017-03-19 21:14:11 +0100
commit151605cacc5939299e0a2ac44477396a56a6e083 (patch)
treedea5a4cebd3f0bc13742c3f37c0fc69e521ce062
parent707aea86bbae6ff819deb64ca977cc701d39d569 (diff)
downloadrneovim-151605cacc5939299e0a2ac44477396a56a6e083.tar.gz
rneovim-151605cacc5939299e0a2ac44477396a56a6e083.tar.bz2
rneovim-151605cacc5939299e0a2ac44477396a56a6e083.zip
vim-patch:8.0.0060
Problem: When using an Ex command for 'keywordprg' it is escaped as with a shell command. (Romain Lafourcade) Solution: Escape for an Ex command. (closes vim/vim#1175) https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
-rw-r--r--src/nvim/normal.c9
-rw-r--r--src/nvim/testdir/test_normal.vim20
2 files changed, 26 insertions, 3 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index ce286042df..49085a27a0 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -4763,9 +4763,14 @@ static void nv_ident(cmdarg_T *cap)
* Now grab the chars in the identifier
*/
if (cmdchar == 'K' && !kp_ex) {
- /* Escape the argument properly for a shell command */
ptr = vim_strnsave(ptr, n);
- p = vim_strsave_shellescape(ptr, true, true);
+ if (kp_ex) {
+ // Escape the argument properly for an Ex command
+ p = vim_strsave_fnameescape(ptr, FALSE);
+ } else {
+ // Escape the argument properly for a shell command
+ p = vim_strsave_shellescape(ptr, TRUE, TRUE);
+ }
xfree(ptr);
char *newbuf = xrealloc(buf, STRLEN(buf) + STRLEN(p) + 1);
buf = newbuf;
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index f896046d4b..20cbaa00f0 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -1222,7 +1222,7 @@ endfunc
func! Test_normal23_K()
" Test for K command
new
- call append(0, ['version8.txt', 'man'])
+ call append(0, ['version8.txt', 'man', 'aa%bb', 'cc|dd'])
let k = &keywordprg
set keywordprg=:help
1
@@ -1237,6 +1237,24 @@ func! Test_normal23_K()
call assert_match('\*version8\.0\*', getline('.'))
helpclose
+ set keywordprg=:new
+ set iskeyword+=%
+ set iskeyword+=\|
+ 2
+ norm! K
+ call assert_equal('man', fnamemodify(bufname('%'), ':t'))
+ bwipe!
+ 3
+ norm! K
+ call assert_equal('aa%bb', fnamemodify(bufname('%'), ':t'))
+ bwipe!
+ 4
+ norm! K
+ call assert_equal('cc|dd', fnamemodify(bufname('%'), ':t'))
+ bwipe!
+ set iskeyword-=%
+ set iskeyword-=\|
+
" Only expect "man" to work on Unix
if !has("unix")
let &keywordprg = k