diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-03-13 03:24:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-13 03:24:09 +0100 |
commit | 7fcf2f926fc6baf43d17ba47cb89d02c0ddc4329 (patch) | |
tree | 73e3893d076aa17e711c0e6e749e6b77d754e61a /src | |
parent | 2af1e232782a54b9af27578f76a2f730261e00ac (diff) | |
download | rneovim-7fcf2f926fc6baf43d17ba47cb89d02c0ddc4329.tar.gz rneovim-7fcf2f926fc6baf43d17ba47cb89d02c0ddc4329.tar.bz2 rneovim-7fcf2f926fc6baf43d17ba47cb89d02c0ddc4329.zip |
TextYankPost: add v:event["inclusive"] #9717
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ops.c | 17 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 10 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 99dee939fc..6a3a404454 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2605,17 +2605,16 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg) static bool recursive = false; if (recursive || !has_event(EVENT_TEXTYANKPOST)) { - // No autocommand was defined - // or we yanked from this autocommand. + // No autocommand was defined, or we yanked from this autocommand. return; } recursive = true; - // set v:event to a dictionary with information about the yank + // Set the v:event dictionary with information about the yank. dict_T *dict = get_vim_var_dict(VV_EVENT); - // the yanked text + // The yanked text contents. list_T *const list = tv_list_alloc((ptrdiff_t)reg->y_size); for (size_t i = 0; i < reg->y_size; i++) { tv_list_append_string(list, (const char *)reg->y_array[i], -1); @@ -2623,17 +2622,21 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg) tv_list_set_lock(list, VAR_FIXED); tv_dict_add_list(dict, S_LEN("regcontents"), list); - // the register type + // Register type. char buf[NUMBUFLEN+2]; format_reg_type(reg->y_type, reg->y_width, buf, ARRAY_SIZE(buf)); tv_dict_add_str(dict, S_LEN("regtype"), buf); - // name of requested register or the empty string for an unnamed operation. + // Name of requested register, or empty string for unnamed operation. buf[0] = (char)oap->regname; buf[1] = NUL; tv_dict_add_str(dict, S_LEN("regname"), buf); - // kind of operation (yank/delete/change) + // Motion type: inclusive or exclusive. + tv_dict_add_special(dict, S_LEN("inclusive"), + oap->inclusive ? kSpecialVarTrue : kSpecialVarFalse); + + // Kind of operation: yank, delete, change). buf[0] = (char)get_op_char(oap->op_type); buf[1] = NUL; tv_dict_add_str(dict, S_LEN("operator"), buf); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index f1fb8e67b9..7a6c9478ca 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1161,23 +1161,23 @@ func Test_TextYankPost() norm "ayiw call assert_equal( - \{'regcontents': ['foo'], 'regname': 'a', 'operator': 'y', 'regtype': 'v'}, + \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'a', 'operator': 'y', 'regtype': 'v'}, \g:event) norm y_ call assert_equal( - \{'regcontents': ['foo'], 'regname': '', 'operator': 'y', 'regtype': 'V'}, + \{'regcontents': ['foo'], 'inclusive': v:false, 'regname': '', 'operator': 'y', 'regtype': 'V'}, \g:event) call feedkeys("\<C-V>y", 'x') call assert_equal( - \{'regcontents': ['f'], 'regname': '', 'operator': 'y', 'regtype': "\x161"}, + \{'regcontents': ['f'], 'inclusive': v:true, 'regname': '', 'operator': 'y', 'regtype': "\x161"}, \g:event) norm "xciwbar call assert_equal( - \{'regcontents': ['foo'], 'regname': 'x', 'operator': 'c', 'regtype': 'v'}, + \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'x', 'operator': 'c', 'regtype': 'v'}, \g:event) norm "bdiw call assert_equal( - \{'regcontents': ['bar'], 'regname': 'b', 'operator': 'd', 'regtype': 'v'}, + \{'regcontents': ['bar'], 'inclusive': v:true, 'regname': 'b', 'operator': 'd', 'regtype': 'v'}, \g:event) call assert_equal({}, v:event) |