-*eval.txt* For Vim version 9.1. Last change: 2025 Dec 11
+*eval.txt* For Vim version 9.1. Last change: 2025 Dec 12
VIM REFERENCE MANUAL by Bram Moolenaar
It should return a |list| or |tuple| containing the following elements in
order:
- 1. Register type (and optional width) conforming to |setreg()|
+ 1. Register type (and optional width) conforming to |setreg()|. If it
+ is an empty string, then the type is automatically chosen.
2. A |list| of strings to return to Vim, each representing a line.
*clipboard-providers-copy*
}
*curval++ = NULL;
- if (STRLEN(reg_type) <= 0
- || get_yank_type(®_type, &yank_type, &block_len) == FAIL)
+ if (*reg_type != NUL && (STRLEN(reg_type) <= 0
+ || get_yank_type(®_type, &yank_type, &block_len) == FAIL))
{
emsg(e_invalid_argument);
goto free_lstval;
// This prevents unnecessary calls when accessing the provider often in an
// interval.
//
-// If -1 then allow provider callback to be called then set to zero. Default
+// If -1 then allow provider callback to be called then set to one. Default
// value (is allowed) is -2.
static int star_pause_count = -2, plus_pause_count = -2;
void
inc_clip_provider(void)
{
- plus_pause_count = plus_pause_count == -2 ? -1 : plus_pause_count + 1;
- star_pause_count = star_pause_count == -2 ? -1 : star_pause_count + 1;
+ plus_pause_count = (plus_pause_count == -2
+ || plus_pause_count == -1) ? -1 : plus_pause_count + 1;
+ star_pause_count = (star_pause_count == -2
+ || star_pause_count == -1) ? -1 : star_pause_count + 1;
}
void
dec_clip_provider(void)
{
- plus_pause_count = plus_pause_count == -1 ? -1 : plus_pause_count - 1;
- star_pause_count = star_pause_count == -1 ? -1 : star_pause_count - 1;
+ if (plus_pause_count != -2)
+ plus_pause_count = plus_pause_count == -1 ? -1 : plus_pause_count - 1;
+ if (star_pause_count != -2)
+ star_pause_count = star_pause_count == -1 ? -1 : star_pause_count - 1;
if (plus_pause_count == 0 || plus_pause_count == -1)
plus_pause_count = -2;
}
#ifdef FEAT_CLIPBOARD_PROVIDER
+ inc_clip_provider();
if (curr == &y_regs[REAL_PLUS_REGISTER])
call_clip_provider_set('+');
else if (curr == &y_regs[STAR_REGISTER])
#if defined(FEAT_EVAL)
if (!deleting && has_textyankpost())
yank_do_autocmd(oap, y_current);
+#endif
+#ifdef FEAT_CLIPBOARD_PROVIDER
+ dec_clip_provider();
#endif
return OK;
elseif l:t == "count"
let g:vim_paste_count[a:reg] += 1
+ let g:vim_test = "hello"
return ("c", ["hello"])
elseif l:t == "store"
call assert_equal(1, g:vim_paste_count['+'])
call assert_equal(1, g:vim_paste_count['*'])
+ call assert_equal(0, g:vim_copy_count['+'])
+ call assert_equal(0, g:vim_copy_count['*'])
+
+ let g:vim_paste_count = {'*': 0, '+': 0}
+
call execute(':global/quick/:yank +')
call execute(':global/quick/:yank *')
call assert_equal(1, g:vim_copy_count['+'])
call assert_equal(1, g:vim_copy_count['*'])
+ call assert_equal(0, g:vim_paste_count['+'])
+ call assert_equal(0, g:vim_paste_count['*'])
+
bw!
set clipmethod&
endfunc
+" Test if the copying does not call the paste callback, and pasting does not all
+" the copy callback.
+func Test_clipboard_provider_copy_paste_independent()
+ let v:clipproviders["test"] = {
+ \ "paste": {
+ \ '+': function("s:Paste"),
+ \ '*': function("s:Paste")
+ \ },
+ \ "copy": {
+ \ '+': function("s:Copy"),
+ \ '*': function("s:Copy")
+ \ }
+ \ }
+ set clipmethod=test
+
+ let g:vim_paste = "count"
+ let g:vim_paste_count = {'*': 0, '+': 0}
+ let g:vim_copy_count = {'*': 0, '+': 0}
+
+ new
+
+ put +
+
+ put *
+
+ bw!
+
+ call getreg("+")
+ call getreg("*")
+
+ call assert_equal(0, g:vim_copy_count['*'])
+ call assert_equal(0, g:vim_copy_count['+'])
+
+ let g:vim_paste_count = {'*': 0, '+': 0}
+
+ " Emitting TextYankPost event may cause a clipboard access
+ augroup Test
+ autocmd!
+ autocmd TextYankPost * let g:test = 2
+ augroup END
+
+ new
+ call setline(1, "The quick brown fox jumps over the lazy dog")
+
+ yank +
+
+ yank *
+
+ bw!
+ autocmd! Test
+
+ call setreg("+", "hello")
+ call setreg("*", "hello")
+
+ call assert_equal(0, g:vim_paste_count['*'])
+ call assert_equal(0, g:vim_paste_count['+'])
+
+ set clipmethod&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1973,
/**/
1972,
/**/