]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work v8.0.0522
authorBram Moolenaar <Bram@vim.org>
Wed, 29 Mar 2017 17:20:41 +0000 (19:20 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 29 Mar 2017 17:20:41 +0000 (19:20 +0200)
Problem:    MS-Windows: when 'clipboard' is "unnamed" yyp does not work in a
            :global command.
Solution:   When setting the clipboard was postponed, do not clear the
            register.

src/Makefile
src/globals.h
src/ops.c
src/proto/ui.pro
src/testdir/test_alot.vim
src/testdir/test_global.vim [new file with mode: 0644]
src/ui.c
src/version.c

index e8314ea6e51b525c0a4c7b29d89b997e8a57c0ad..82da653e741cbc10a203df9aac039c4412fb15f4 100644 (file)
@@ -2145,6 +2145,7 @@ test_arglist \
        test_ga \
        test_gf \
        test_glob2regpat \
+       test_global \
        test_gn \
        test_goto \
        test_gui \
index 59193e07a7e2c7712a46966696d281e38bd44043..28b71ac8511f3a4d0d8fcd5bd39be0d7dfbe8224 100644 (file)
@@ -532,7 +532,6 @@ EXTERN int  clip_autoselect_plus INIT(= FALSE);
 EXTERN int     clip_autoselectml INIT(= FALSE);
 EXTERN int     clip_html INIT(= FALSE);
 EXTERN regprog_T *clip_exclude_prog INIT(= NULL);
-EXTERN int     clip_did_set_selection INIT(= TRUE);
 EXTERN int     clip_unnamed_saved INIT(= 0);
 #endif
 
index 9cff1bcf03a09689ecde99955d3ff04dbee508e3..7cbc0c22cb8e0e9570e50c5a781bfa5093bdb059 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -6466,7 +6466,7 @@ clip_get_selection(VimClipboard *cbd)
        VIsual = old_visual;
        VIsual_mode = old_visual_mode;
     }
-    else
+    else if (!is_clipboard_needs_update())
     {
        clip_free_selection(cbd);
 
index dbb7213963899a489f1fcc435bcb7778b6ed20dc..47c0fef684c62743b69debe014f04e9a85fb254d 100644 (file)
@@ -16,6 +16,7 @@ void clip_update_selection(VimClipboard *clip);
 void clip_own_selection(VimClipboard *cbd);
 void clip_lose_selection(VimClipboard *cbd);
 void start_global_changes(void);
+int is_clipboard_needs_update(void);
 void end_global_changes(void);
 void clip_auto_select(void);
 int clip_isautosel_star(void);
index 7b31575ae9f3088fc361ed6d77aba83717949309..56a3f8edf52c5c70d0465a2e27bd3438bcdedcf9 100644 (file)
@@ -21,8 +21,9 @@ source test_findfile.vim
 source test_float_func.vim
 source test_fnamemodify.vim
 source test_functions.vim
-source test_glob2regpat.vim
 source test_ga.vim
+source test_glob2regpat.vim
+source test_global.vim
 source test_goto.vim
 source test_help_tagjump.vim
 source test_join.vim
diff --git a/src/testdir/test_global.vim b/src/testdir/test_global.vim
new file mode 100644 (file)
index 0000000..be8aa69
--- /dev/null
@@ -0,0 +1,11 @@
+
+func Test_yank_put_clipboard()
+  new
+  call setline(1, ['a', 'b', 'c'])
+  set clipboard=unnamed
+  g/^/normal yyp
+  call assert_equal(['a', 'a', 'b', 'b', 'c', 'c'], getline(1, 6))
+
+  set clipboard&
+  bwipe!
+endfunc
index 0bd2edc93c1fbb22eadfc90fc5fb08d6f60d4a84..8691ab741a4da87b49107f0110e3ac9be209feee 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -392,8 +392,6 @@ ui_breakcheck_force(int force)
 
 #if defined(FEAT_CLIPBOARD) || defined(PROTO)
 
-static void clip_copy_selection(VimClipboard *clip);
-
 /*
  * Selection stuff using Visual mode, for cutting and pasting text to other
  * windows.
@@ -569,7 +567,8 @@ clip_copy_selection(VimClipboard *clip)
  * considerably.
  */
 static int global_change_count = 0; /* if set, inside a start_global_changes */
-static int clipboard_needs_update; /* clipboard needs to be updated */
+static int clipboard_needs_update = FALSE; /* clipboard needs to be updated */
+static int clip_did_set_selection = TRUE;
 
 /*
  * Save clip_unnamed and reset it.
@@ -589,6 +588,16 @@ start_global_changes(void)
     }
 }
 
+/*
+ * Return TRUE if setting the clipboard was postponed, it already contains the
+ * right text.
+ */
+    int
+is_clipboard_needs_update()
+{
+    return clipboard_needs_update;
+}
+
 /*
  * Restore clip_unnamed and set the selection when needed.
  */
@@ -619,6 +628,7 @@ end_global_changes(void)
            }
        }
     }
+    clipboard_needs_update = FALSE;
 }
 
 /*
index 539052b51102219034350d68f602c075866ce211..90ec27bf811bd1423ee44bf2e0ea1d5ed414b74f 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    522,
 /**/
     521,
 /**/