Skip to content

Commit a0b003e

Browse files
brammooldouglaskayama
authored andcommitted
updated for version 7.4.598
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)
1 parent d43c5e0 commit a0b003e

5 files changed

Lines changed: 45 additions & 26 deletions

File tree

src/main.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -959,17 +959,8 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
959959
if (p_im)
960960
need_start_insertmode = TRUE;
961961

962-
#ifdef FEAT_CLIPBOARD
963-
if (clip_unnamed)
964-
/* do not overwrite system clipboard while starting up */
965-
clip_did_set_selection = -1;
966-
#endif
967962
#ifdef FEAT_AUTOCMD
968963
apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf);
969-
# ifdef FEAT_CLIPBOARD
970-
if (clip_did_set_selection < 0)
971-
clip_did_set_selection = TRUE;
972-
# endif
973964
TIME_MSG("VimEnter autocommands");
974965
#endif
975966

src/testdir/test_eval.in

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Test for various eval features. vim: set ft=vim :
22

3-
Note: system clipboard support is not tested. I do not think anybody will thank
4-
me for messing with clipboard.
3+
Note: system clipboard is saved, changed and restored.
54

65
STARTTEST
76
:so small.vim
@@ -122,7 +121,19 @@ call SetReg('/', ['abc/'])
122121
call SetReg('/', ["abc/\n"])
123122
call SetReg('=', ['"abc/"'])
124123
call SetReg('=', ["\"abc/\n\""])
125-
124+
$put ='{{{1 System clipboard'
125+
" Save and restore system clipboard.
126+
" If no connection to X-Server is possible, test should succeed.
127+
:let _clipreg = ['+', getreg('+'), getregtype('+')]
128+
:let _clipopt = &cb
129+
:let &cb='unnamedplus'
130+
:1y
131+
:AR +
132+
:tabdo :windo :echo "hi"
133+
:3y
134+
:AR +
135+
:let &cb=_clipopt
136+
:call call('setreg', _clipreg)
126137
$put ='{{{1 Errors'
127138
call ErrExe('call setreg()')
128139
call ErrExe('call setreg(1)')

src/testdir/test_eval.ok

528 Bytes
Binary file not shown.

src/ui.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ ui_write(s, len)
7373
static char_u *ta_str = NULL;
7474
static int ta_off; /* offset for next char to use when ta_str != NULL */
7575
static int ta_len; /* length of ta_str when it's not NULL*/
76+
static int clipboard_needs_update; /* clipboard needs to be updated */
77+
static int global_change_count = 0; /* if set, inside a start_global_changes */
7678

7779
void
7880
ui_inchar_undo(s, len)
@@ -569,9 +571,12 @@ clip_copy_selection(clip)
569571
void
570572
start_global_changes()
571573
{
574+
if (++global_change_count > 1)
575+
return;
572576
clip_unnamed_saved = clip_unnamed;
577+
clipboard_needs_update = FALSE;
573578

574-
if (clip_did_set_selection > 0)
579+
if (clip_did_set_selection)
575580
{
576581
clip_unnamed = FALSE;
577582
clip_did_set_selection = FALSE;
@@ -584,22 +589,30 @@ start_global_changes()
584589
void
585590
end_global_changes()
586591
{
587-
if (clip_did_set_selection == FALSE) /* not when -1 */
592+
if (--global_change_count > 0)
593+
/* recursive */
594+
return;
595+
if (!clip_did_set_selection)
588596
{
589597
clip_did_set_selection = TRUE;
590598
clip_unnamed = clip_unnamed_saved;
591-
if (clip_unnamed & CLIP_UNNAMED)
599+
clip_unnamed_saved = FALSE;
600+
if (clipboard_needs_update)
592601
{
593-
clip_own_selection(&clip_star);
594-
clip_gen_set_selection(&clip_star);
595-
}
596-
if (clip_unnamed & CLIP_UNNAMED_PLUS)
597-
{
598-
clip_own_selection(&clip_plus);
599-
clip_gen_set_selection(&clip_plus);
602+
/* only store something in the clipboard,
603+
* if we have yanked anything to it */
604+
if (clip_unnamed & CLIP_UNNAMED)
605+
{
606+
clip_own_selection(&clip_star);
607+
clip_gen_set_selection(&clip_star);
608+
}
609+
if (clip_unnamed & CLIP_UNNAMED_PLUS)
610+
{
611+
clip_own_selection(&clip_plus);
612+
clip_gen_set_selection(&clip_plus);
613+
}
600614
}
601615
}
602-
clip_unnamed_saved = FALSE;
603616
}
604617

605618
/*
@@ -1477,10 +1490,12 @@ clip_gen_set_selection(cbd)
14771490
{
14781491
/* Updating postponed, so that accessing the system clipboard won't
14791492
* hang Vim when accessing it many times (e.g. on a :g comand). */
1480-
if (cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS))
1481-
return;
1482-
else if (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED))
1493+
if ((cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS))
1494+
|| (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED)))
1495+
{
1496+
clipboard_needs_update = TRUE;
14831497
return;
1498+
}
14841499
}
14851500
#ifdef FEAT_XCLIPBOARD
14861501
# ifdef FEAT_GUI

src/version.c

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

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
598,
744746
/**/
745747
597,
746748
/**/

0 commit comments

Comments
 (0)