On Sa, 13 Sep 2014, Bram Moolenaar wrote:

> Not really.  Perhaps end_global_changes() clears the clipboard in a
> specific sequence of events?  There might be a race condition, causing
> it to work when running in gdb.  Or with/without using the optimizer?

Oh why, didn't I see this? I feel so stupid. Yes that is basically what
happens. end_global_changes() calls clip_gen_set_selection() which
clears the clipboard, which it shouldn't when starting up.

I couldn't reproduce it, because I usually run vim from it's built 
directory, and in this case the netrw plugin wasn't executed...

diff --git a/src/main.c b/src/main.c
--- a/src/main.c
+++ b/src/main.c
@@ -958,8 +958,16 @@ vim_main2(int argc UNUSED, char **argv U
     if (p_im)
        need_start_insertmode = TRUE;
 
+#ifdef FEAT_CLIPBOARD
+    if (clip_unnamed)
+       clip_did_set_selection = -1; /* do not overwrite system clipboard, when 
starting up */
+#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
 
diff --git a/src/ui.c b/src/ui.c
--- a/src/ui.c
+++ b/src/ui.c
@@ -571,7 +571,7 @@ start_global_changes()
 {
     clip_unnamed_saved = clip_unnamed;
 
-    if (clip_did_set_selection)
+    if (clip_did_set_selection > 0)
     {
        clip_unnamed = FALSE;
        clip_did_set_selection = FALSE;
@@ -584,7 +584,7 @@ start_global_changes()
     void
 end_global_changes()
 {
-    if (!clip_did_set_selection)
+    if (clip_did_set_selection == 0)
     {
        clip_did_set_selection = TRUE;
        clip_unnamed = clip_unnamed_saved;


Best,
Christian
-- 
Was man mündlich ausspricht, muss der Gegenwart, dem Augenblick 
gewidmet sein; was man schreibt, widme man der Ferne, der Folge.
                -- Goethe, Maximen und Reflektionen, Nr. 585

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui