]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.4.598 v7.4.598
authorBram Moolenaar <Bram@vim.org>
Tue, 27 Jan 2015 13:09:37 +0000 (14:09 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 27 Jan 2015 13:09:37 +0000 (14:09 +0100)
Problem:    ":tabdo windo echo 'hi'" causes "* register not to be changed.
            (Salman Halim)
Solution:   Change how clip_did_set_selection is used and add
            clipboard_needs_update and global_change_count.  (Christian
            Brabandt)

src/main.c
src/testdir/test_eval.in
src/testdir/test_eval.ok
src/ui.c
src/version.c

index 1814385197b7da005bde3d83fbeda5cff86c5fd1..ec83d8f14980e077822471eb6a51a97c38a42df3 100644 (file)
@@ -959,17 +959,8 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
     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
 
index cd605af56eb74a7e514a9d3c5617bc9d49f997f5..b9f68f75c7c6cb66ff414d44b467aa666050c9df 100644 (file)
@@ -1,7 +1,6 @@
 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
@@ -122,7 +121,19 @@ call SetReg('/', ['abc/'])
 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)')
index 59112d028e72a937287ae2d2b7e60a0a03bd4493..5e8d2cc4f6f0caa2b4386ceec8b3addb70c419a2 100644 (file)
Binary files a/src/testdir/test_eval.ok and b/src/testdir/test_eval.ok differ
index 59794829d8c7ef039ccca6f558b7a4a31d8c625a..a2d83458d5358c97b137761ba13cb0aa47eef8fe 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -73,6 +73,8 @@ ui_write(s, len)
 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)
@@ -569,9 +571,12 @@ clip_copy_selection(clip)
     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;
@@ -584,22 +589,30 @@ start_global_changes()
     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;
 }
 
 /*
@@ -1477,10 +1490,12 @@ clip_gen_set_selection(cbd)
     {
        /* 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
index f0107fabf4f0ed2bfbd0e683f42ba335d687ae9e..35a716058ef0afce9d2472b309aca9acc310a176 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    598,
 /**/
     597,
 /**/