On Mi, 18 Jun 2014, Praful wrote: > On Friday, 13 June 2014 15:50:50 UTC+1, Christian Brabandt wrote: > > Hi Bram! > > > > > > > > On Do, 12 Jun 2014, Bram Moolenaar wrote: > > > > > > > > > Almost. This code now uses clip_did_set_selection for two purposes. I > > > > > would reset clip_unnamed before calling global_exe(), where you set > > > > > clip_did_set_selection to FALSE. Simlarly in ex_listdo(). > > > > > > > > I wouldn't. Saves us an another global variable and makes > > > > adjust_clip_reg() just work. And it isn't actually needed is it? > > > > > > > > > Oh, and move the calls to clip_own_selection() to a function, instead of > > > > > copying this code to three places. That function would then also > > > > > restore clip_unnamed. > > > > > > > > Ok that would work. Here is an updated patch. > > I have tried this patch and it made no difference! It's still slow when I try > g!/<pattern>/d. Using d_ was fine as expected.
Sorry, typo. Please try this updated patch. Best, Christian -- Die Liebe ist unsere Strafe dafür, daß wir es nicht einfach bei der Fortpflanzung bewenden lassen. -- Helmar Nahr -- -- 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 vim_dev+unsubscr...@googlegroups.com. 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,18 @@ ex_global(eap) smsg((char_u *)_("Pattern not found: %s"), pat); } else + { +#ifdef FEAT_CLIPBOARD + start_global_changes(); +#endif global_exe(cmd); + } ml_clearmarked(); /* clear rest of the marks */ vim_regfree(regmatch.regprog); +#ifdef FEAT_CLIPBOARD + end_global_changes(); +#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 + start_global_changes(); +#endif if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo @@ -2591,6 +2594,9 @@ ex_listdo(eap) curbuf->b_fname, TRUE, curbuf); } #endif +#ifdef FEAT_CLIPBOARD + end_global_changes(); +#endif } /* diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -11534,6 +11534,10 @@ ex_folddo(eap) { linenr_T lnum; +#ifdef FEAT_CLIPBOARD + start_global_changes(); +#endif + /* First set the marks for all lines closed/open. */ for (lnum = eap->line1; lnum <= eap->line2; ++lnum) if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) @@ -11542,5 +11546,8 @@ 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 + end_global_changes(); +#endif +} +#endif diff --git a/src/globals.h b/src/globals.h --- a/src/globals.h +++ b/src/globals.h @@ -531,6 +531,8 @@ 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); +EXTERN int clip_unnamed_saved INIT(= 0); #endif /* diff --git a/src/ops.c b/src/ops.c --- a/src/ops.c +++ b/src/ops.c @@ -1594,9 +1594,15 @@ adjust_clip_reg(rp) { /* If no reg. specified, and "unnamed" or "unnamedplus" is in 'clipboard', * use '*' or '+' reg, respectively. "unnamedplus" prevails. */ - if (*rp == 0 && clip_unnamed != 0) - *rp = ((clip_unnamed & CLIP_UNNAMED_PLUS) && clip_plus.available) + if (*rp == 0 && (clip_unnamed != 0 || clip_unnamed_saved != 0)) + { + if (clip_unnamed != 0) + *rp = ((clip_unnamed & CLIP_UNNAMED_PLUS) && clip_plus.available) ? '+' : '*'; + else + *rp = ((clip_unnamed_saved & CLIP_UNNAMED_PLUS) && clip_plus.available) + ? '+' : '*'; + } if (!clip_star.available && *rp == '*') *rp = 0; if (!clip_plus.available && *rp == '+') 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/proto/ui.pro b/src/proto/ui.pro --- a/src/proto/ui.pro +++ b/src/proto/ui.pro @@ -14,6 +14,8 @@ void clip_init __ARGS((int can_use)); void clip_update_selection __ARGS((VimClipboard *clip)); void clip_own_selection __ARGS((VimClipboard *cbd)); void clip_lose_selection __ARGS((VimClipboard *cbd)); +void start_global_changes __ARGS((void)); +void end_global_changes __ARGS((void)); void clip_auto_select __ARGS((void)); int clip_isautosel_star __ARGS((void)); int clip_isautosel_plus __ARGS((void)); 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 times (e.g. on a :g comand) */ + if (!clip_did_set_selection) + { + if (cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS)) + return; + else if (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED)) + return; + } /* * Also want to check somehow that we are reading from the keyboard rather * than a mapping etc. @@ -557,6 +566,37 @@ clip_copy_selection(clip) } } +/* Save and restore clip_unnamed before doing possibly many changes. This prevents + * accessing the clipboard very often which might slow down Vim considerably */ + +/* Save clip_unnamed and reset it */ + void +start_global_changes() +{ + + clip_unnamed_saved = clip_unnamed; + + if (clip_did_set_selection) + { + clip_unnamed = FALSE; + clip_did_set_selection = FALSE; + } +} + void +end_global_changes() +{ + if (!clip_did_set_selection) + { + clip_did_set_selection = TRUE; + clip_unnamed = clip_unnamed_saved; + if (clip_unnamed & CLIP_UNNAMED) + clip_own_selection(&clip_star); + if (clip_unnamed & CLIP_UNNAMED_PLUS) + clip_own_selection(&clip_plus); + } + clip_unnamed_saved = FALSE; +} + /* * Called when Visual mode is ended: update the selection. */