if (p_im)
need_start_insertmode = TRUE;
-#ifdef FEAT_CLIPBOARD
- if (clip_unnamed)
- /* do not overwrite system clipboard while starting up */
- clip_did_set_selection = -1;
-#endif
#ifdef FEAT_AUTOCMD
apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf);
-# ifdef FEAT_CLIPBOARD
- if (clip_did_set_selection < 0)
- clip_did_set_selection = TRUE;
-# endif
TIME_MSG("VimEnter autocommands");
#endif
Test for various eval features. vim: set ft=vim :
-Note: system clipboard support is not tested. I do not think anybody will thank
-me for messing with clipboard.
+Note: system clipboard is saved, changed and restored.
STARTTEST
:so small.vim
call SetReg('/', ["abc/\n"])
call SetReg('=', ['"abc/"'])
call SetReg('=', ["\"abc/\n\""])
-
+$put ='{{{1 System clipboard'
+" Save and restore system clipboard.
+" If no connection to X-Server is possible, test should succeed.
+:let _clipreg = ['+', getreg('+'), getregtype('+')]
+:let _clipopt = &cb
+:let &cb='unnamedplus'
+:1y
+:AR +
+:tabdo :windo :echo "hi"
+:3y
+:AR +
+:let &cb=_clipopt
+:call call('setreg', _clipreg)
$put ='{{{1 Errors'
call ErrExe('call setreg()')
call ErrExe('call setreg(1)')
static char_u *ta_str = NULL;
static int ta_off; /* offset for next char to use when ta_str != NULL */
static int ta_len; /* length of ta_str when it's not NULL*/
+static int clipboard_needs_update; /* clipboard needs to be updated */
+static int global_change_count = 0; /* if set, inside a start_global_changes */
void
ui_inchar_undo(s, len)
void
start_global_changes()
{
+ if (++global_change_count > 1)
+ return;
clip_unnamed_saved = clip_unnamed;
+ clipboard_needs_update = FALSE;
- if (clip_did_set_selection > 0)
+ if (clip_did_set_selection)
{
clip_unnamed = FALSE;
clip_did_set_selection = FALSE;
void
end_global_changes()
{
- if (clip_did_set_selection == FALSE) /* not when -1 */
+ if (--global_change_count > 0)
+ /* recursive */
+ return;
+ if (!clip_did_set_selection)
{
clip_did_set_selection = TRUE;
clip_unnamed = clip_unnamed_saved;
- if (clip_unnamed & CLIP_UNNAMED)
+ clip_unnamed_saved = FALSE;
+ if (clipboard_needs_update)
{
- clip_own_selection(&clip_star);
- clip_gen_set_selection(&clip_star);
- }
- if (clip_unnamed & CLIP_UNNAMED_PLUS)
- {
- clip_own_selection(&clip_plus);
- clip_gen_set_selection(&clip_plus);
+ /* only store something in the clipboard,
+ * if we have yanked anything to it */
+ if (clip_unnamed & CLIP_UNNAMED)
+ {
+ clip_own_selection(&clip_star);
+ clip_gen_set_selection(&clip_star);
+ }
+ if (clip_unnamed & CLIP_UNNAMED_PLUS)
+ {
+ clip_own_selection(&clip_plus);
+ clip_gen_set_selection(&clip_plus);
+ }
}
}
- clip_unnamed_saved = FALSE;
}
/*
{
/* Updating postponed, so that accessing the system clipboard won't
* hang Vim when accessing it many times (e.g. on a :g comand). */
- if (cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS))
- return;
- else if (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED))
+ if ((cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS))
+ || (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED)))
+ {
+ clipboard_needs_update = TRUE;
return;
+ }
}
#ifdef FEAT_XCLIPBOARD
# ifdef FEAT_GUI