diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-17 17:14:25 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-17 17:36:40 -0400 |
commit | 3d71366af1287f356a812a38f2c0b22230fe409c (patch) | |
tree | 81b03f32dac9257ab411c247c8e2b3e6a93bc0dc /src | |
parent | f53c95e7a8cbeb6fb523d179ae166a3ace87dbcd (diff) | |
download | rneovim-3d71366af1287f356a812a38f2c0b22230fe409c.tar.gz rneovim-3d71366af1287f356a812a38f2c0b22230fe409c.tar.bz2 rneovim-3d71366af1287f356a812a38f2c0b22230fe409c.zip |
vim-patch:8.0.1090: cannot get the text under the cursor like v:beval_text
Problem: cannot get the text under the cursor like v:beval_text
Solution: Add <cexpr>.
https://github.com/vim/vim/commit/65f084749b260746d7f186af4f080298be2df55b
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_docmd.c | 34 | ||||
-rw-r--r-- | src/nvim/testdir/test_normal.vim | 20 |
2 files changed, 37 insertions, 17 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 076e77be6a..97e09b8869 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8392,23 +8392,25 @@ ssize_t find_cmdline_var(const char_u *src, size_t *usedlen) "%", #define SPEC_PERC 0 "#", -#define SPEC_HASH 1 +#define SPEC_HASH (SPEC_PERC + 1) "<cword>", /* cursor word */ -#define SPEC_CWORD 2 +#define SPEC_CWORD (SPEC_HASH + 1) "<cWORD>", /* cursor WORD */ -#define SPEC_CCWORD 3 +#define SPEC_CCWORD (SPEC_CWORD + 1) + "<cexpr>", // expr under cursor +#define SPEC_CEXPR (SPEC_CCWORD + 1) "<cfile>", /* cursor path name */ -#define SPEC_CFILE 4 +#define SPEC_CFILE (SPEC_CEXPR + 1) "<sfile>", /* ":so" file name */ -#define SPEC_SFILE 5 +#define SPEC_SFILE (SPEC_CFILE + 1) "<slnum>", /* ":so" file line number */ -#define SPEC_SLNUM 6 +#define SPEC_SLNUM (SPEC_SFILE + 1) "<afile>", /* autocommand file name */ -# define SPEC_AFILE 7 +#define SPEC_AFILE (SPEC_SLNUM + 1) "<abuf>", /* autocommand buffer number */ -# define SPEC_ABUF 8 +#define SPEC_ABUF (SPEC_AFILE + 1) "<amatch>", /* autocommand match name */ -# define SPEC_AMATCH 9 +#define SPEC_AMATCH (SPEC_ABUF + 1) }; for (size_t i = 0; i < ARRAY_SIZE(spec_str); ++i) { @@ -8489,10 +8491,16 @@ eval_vars ( /* * word or WORD under cursor */ - if (spec_idx == SPEC_CWORD || spec_idx == SPEC_CCWORD) { - resultlen = find_ident_under_cursor(&result, (spec_idx == SPEC_CWORD - ? (FIND_IDENT|FIND_STRING) - : FIND_STRING)); + if (spec_idx == SPEC_CWORD + || spec_idx == SPEC_CCWORD + || spec_idx == SPEC_CEXPR) { + resultlen = find_ident_under_cursor( + &result, + spec_idx == SPEC_CWORD + ? (FIND_IDENT | FIND_STRING) + : (spec_idx == SPEC_CEXPR + ? (FIND_IDENT | FIND_STRING | FIND_EVAL) + : FIND_STRING)); if (resultlen == 0) { *errormsg = (char_u *)""; return NULL; diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 4c63bd1f71..035c778749 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -392,10 +392,22 @@ func! Test_normal10_expand() call setline(1, ['1', 'ifooar,,cbar']) 2 norm! $ - let a=expand('<cword>') - let b=expand('<cWORD>') - call assert_equal('cbar', a) - call assert_equal('ifooar,,cbar', b) + call assert_equal('cbar', expand('<cword>')) + call assert_equal('ifooar,,cbar', expand('<cWORD>')) + + call setline(1, ['prx = list[idx];']) + 1 + let expected = ['', 'prx', 'prx', 'prx', + \ 'list', 'list', 'list', 'list', 'list', 'list', 'list', + \ 'idx', 'idx', 'idx', 'idx', + \ 'list[idx]', + \ '];', + \ ] + for i in range(1, 16) + exe 'norm ' . i . '|' + call assert_equal(expected[i], expand('<cexpr>'), 'i == ' . i) + endfor + " clean up bw! endfunc |