On So, 08 Jun 2014, Bram Moolenaar wrote:
> Christian wrote:
>
> > On So, 01 Jun 2014, Bram Moolenaar wrote:
> > > When restoring clip_unnamed, it's not too dificult to set the
> > > clipboard then. Would require checking that it would have been set
> > > (default register changed). Then the remarks about "doesn't work for
> > > some commands" can be changed to "for some commands disabled until the
> > > end". I'm sure this avoids surprises for users.
> >
> > I am not sure how to do it.
>
> This would require a flag, e.g. "did_set_selection". When resetting
> clip_unnamed before doing a global operation, this flag would be reset.
> Then when text is deleted or yanked, clip_own_selection() will be
> called, and if the register used matches the register that would be
> associated with clip_unnamed, then set the "did_set_selection" flag.
> When restoring clip_unnamed, check if "did_set_selection" was set, and
> if it is call clip_own_selection() to get the current unnamed register
> into the clipboard.
>
> It's a bit sketchy, there are probably a few more details to work out,
> but basically it would work to avoid putting text on the clipboard many
> times and still end up with the correct clipboard contents in the end.
> If we can make this work properly we can avoid users having to be aware
> of this and just enjoy the much faster operation.
Okay, I think I understood. Here is a patch.
Best,
Christian
--
Nicht durch Zorn, sondern durch Lachen tötet man.
-- Friedrich Wilhelm Nietzsche (Also sprach Zarathustra)
--
--
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.
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -5511,10 +5511,27 @@ ex_global(eap)
smsg((char_u *)_("Pattern not found: %s"), pat);
}
else
+ {
+#ifdef FEAT_CLIPBOARD
+ if (ndone > 100)
+ /* reset clipboard for more then 100 matches (prevents hanging Windows) */
+ clip_did_set_selection = FALSE;
+#endif
global_exe(cmd);
+ }
ml_clearmarked(); /* clear rest of the marks */
vim_regfree(regmatch.regprog);
+#ifdef FEAT_CLIPBOARD
+ if (clip_did_set_selection)
+ {
+ if (clip_unnamed & CLIP_UNNAMED)
+ clip_own_selection(&clip_star);
+ else if (clip_unnamed & CLIP_UNNAMED_PLUS)
+ clip_own_selection(&clip_plus);
+ }
+ clip_did_set_selection = TRUE;
+#endif
}
/*
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2464,6 +2464,9 @@ ex_listdo(eap)
* great speed improvement. */
save_ei = au_event_disable(",Syntax");
#endif
+#ifdef FEAT_CLIPBOARD
+ clip_did_set_selection = FALSE;
+#endif
if (eap->cmdidx == CMD_windo
|| eap->cmdidx == CMD_tabdo
@@ -2591,6 +2594,16 @@ ex_listdo(eap)
curbuf->b_fname, TRUE, curbuf);
}
#endif
+#ifdef FEAT_CLIPBOARD
+ if (clip_did_set_selection)
+ {
+ if (clip_unnamed & CLIP_UNNAMED)
+ clip_own_selection(&clip_star);
+ else if (clip_unnamed & CLIP_UNNAMED_PLUS)
+ clip_own_selection(&clip_plus);
+ }
+ clip_did_set_selection = TRUE;
+#endif
}
/*
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -11533,6 +11533,9 @@ ex_folddo(eap)
exarg_T *eap;
{
linenr_T lnum;
+#ifdef FEAT_CLIPBOARD
+ clip_did_set_selection = FALSE;
+#endif
/* First set the marks for all lines closed/open. */
for (lnum = eap->line1; lnum <= eap->line2; ++lnum)
@@ -11542,5 +11545,15 @@ ex_folddo(eap)
/* Execute the command on the marked lines. */
global_exe(eap->arg);
ml_clearmarked(); /* clear rest of the marks */
-}
-#endif
+#ifdef FEAT_CLIPBOARD
+ if (clip_did_set_selection)
+ {
+ if (clip_unnamed & CLIP_UNNAMED)
+ clip_own_selection(&clip_star);
+ else if (clip_unnamed & CLIP_UNNAMED_PLUS)
+ clip_own_selection(&clip_plus);
+ }
+ clip_did_set_selection = TRUE;
+#endif
+}
+#endif
diff --git a/src/globals.h b/src/globals.h
--- a/src/globals.h
+++ b/src/globals.h
@@ -531,6 +531,7 @@ EXTERN int clip_autoselect_plus INIT(= F
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);
#endif
/*
diff --git a/src/proto/ops.pro b/src/proto/ops.pro
--- a/src/proto/ops.pro
+++ b/src/proto/ops.pro
@@ -59,4 +59,5 @@ void write_reg_contents_ex __ARGS((int n
void write_reg_contents_lst __ARGS((int name, char_u **strings, int maxlen, int must_append, int yank_type, long block_len));
void clear_oparg __ARGS((oparg_T *oap));
void cursor_pos_info __ARGS((void));
+void copy_yank_to_clipboard __ARGS((VimClipboard *cbd));
/* vim: set ft=c : */
diff --git a/src/ui.c b/src/ui.c
--- a/src/ui.c
+++ b/src/ui.c
@@ -466,6 +466,15 @@ clip_update_selection(clip)
clip_own_selection(cbd)
VimClipboard *cbd;
{
+ /* updating postponed, so that accessing the system clipboard won't hang
+ * vim when accessing it many ties (e.g. on a :g comand) */
+ if (!clip_did_set_selection)
+ {
+ if (cbd == &clip_plus && (clip_unnamed & CLIP_UNNAMED_PLUS))
+ return;
+ else if (cbd == &clip_star && (clip_unnamed & CLIP_UNNAMED))
+ return;
+ }
/*
* Also want to check somehow that we are reading from the keyboard rather
* than a mapping etc.