Skip to content

Commit 3fcfa35

Browse files
committed
patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
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.
1 parent 99a6e8d commit 3fcfa35

8 files changed

Lines changed: 31 additions & 6 deletions

File tree

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,7 @@ test_arglist \
21452145
test_ga \
21462146
test_gf \
21472147
test_glob2regpat \
2148+
test_global \
21482149
test_gn \
21492150
test_goto \
21502151
test_gui \

src/globals.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ EXTERN int clip_autoselect_plus INIT(= FALSE);
532532
EXTERN int clip_autoselectml INIT(= FALSE);
533533
EXTERN int clip_html INIT(= FALSE);
534534
EXTERN regprog_T *clip_exclude_prog INIT(= NULL);
535-
EXTERN int clip_did_set_selection INIT(= TRUE);
536535
EXTERN int clip_unnamed_saved INIT(= 0);
537536
#endif
538537

src/ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6466,7 +6466,7 @@ clip_get_selection(VimClipboard *cbd)
64666466
VIsual = old_visual;
64676467
VIsual_mode = old_visual_mode;
64686468
}
6469-
else
6469+
else if (!is_clipboard_needs_update())
64706470
{
64716471
clip_free_selection(cbd);
64726472

src/proto/ui.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void clip_update_selection(VimClipboard *clip);
1616
void clip_own_selection(VimClipboard *cbd);
1717
void clip_lose_selection(VimClipboard *cbd);
1818
void start_global_changes(void);
19+
int is_clipboard_needs_update(void);
1920
void end_global_changes(void);
2021
void clip_auto_select(void);
2122
int clip_isautosel_star(void);

src/testdir/test_alot.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ source test_findfile.vim
2121
source test_float_func.vim
2222
source test_fnamemodify.vim
2323
source test_functions.vim
24-
source test_glob2regpat.vim
2524
source test_ga.vim
25+
source test_glob2regpat.vim
26+
source test_global.vim
2627
source test_goto.vim
2728
source test_help_tagjump.vim
2829
source test_join.vim

src/testdir/test_global.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
func Test_yank_put_clipboard()
3+
new
4+
call setline(1, ['a', 'b', 'c'])
5+
set clipboard=unnamed
6+
g/^/normal yyp
7+
call assert_equal(['a', 'a', 'b', 'b', 'c', 'c'], getline(1, 6))
8+
9+
set clipboard&
10+
bwipe!
11+
endfunc

src/ui.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,6 @@ ui_breakcheck_force(int force)
392392

393393
#if defined(FEAT_CLIPBOARD) || defined(PROTO)
394394

395-
static void clip_copy_selection(VimClipboard *clip);
396-
397395
/*
398396
* Selection stuff using Visual mode, for cutting and pasting text to other
399397
* windows.
@@ -569,7 +567,8 @@ clip_copy_selection(VimClipboard *clip)
569567
* considerably.
570568
*/
571569
static int global_change_count = 0; /* if set, inside a start_global_changes */
572-
static int clipboard_needs_update; /* clipboard needs to be updated */
570+
static int clipboard_needs_update = FALSE; /* clipboard needs to be updated */
571+
static int clip_did_set_selection = TRUE;
573572

574573
/*
575574
* Save clip_unnamed and reset it.
@@ -589,6 +588,16 @@ start_global_changes(void)
589588
}
590589
}
591590

591+
/*
592+
* Return TRUE if setting the clipboard was postponed, it already contains the
593+
* right text.
594+
*/
595+
int
596+
is_clipboard_needs_update()
597+
{
598+
return clipboard_needs_update;
599+
}
600+
592601
/*
593602
* Restore clip_unnamed and set the selection when needed.
594603
*/
@@ -619,6 +628,7 @@ end_global_changes(void)
619628
}
620629
}
621630
}
631+
clipboard_needs_update = FALSE;
622632
}
623633

624634
/*

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
522,
767769
/**/
768770
521,
769771
/**/

0 commit comments

Comments
 (0)