summaryrefslogtreecommitdiff
path: root/src/ui.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-08-06 18:17:11 +0200
committerBram Moolenaar <Bram@vim.org>2014-08-06 18:17:11 +0200
commit6b1ee34aa0236b50f675f3bbcd9bf0b7a3384f7f (patch)
tree0f3f8952da9b62bc8d344394f549cbcf4fdf4f3b /src/ui.c
parent04d17ae1678846c4857cd86cf3eaf47d60c04c85 (diff)
downloadvim-git-6b1ee34aa0236b50f675f3bbcd9bf0b7a3384f7f.tar.gz
updated for version 7.4.396v7.4.396
Problem: When 'clipboard' is "unnamed", :g/pat/d is very slow. (Praful) Solution: Only set the clipboard after the last delete. (Christian Brabandt)
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/ui.c b/src/ui.c
index db13555f4..21d92f0b7 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -558,6 +558,51 @@ 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;
+ }
+}
+
+/*
+ * Restore clip_unnamed and set the selection when needed.
+ */
+ 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);
+ clip_gen_set_selection(&clip_star);
+ }
+ if (clip_unnamed & CLIP_UNNAMED_PLUS)
+ {
+ clip_own_selection(&clip_plus);
+ clip_gen_set_selection(&clip_plus);
+ }
+ }
+ clip_unnamed_saved = FALSE;
+}
+
+/*
* Called when Visual mode is ended: update the selection.
*/
void
@@ -1428,6 +1473,15 @@ clip_gen_lose_selection(cbd)
clip_gen_set_selection(cbd)
VimClipboard *cbd;
{
+ if (!clip_did_set_selection)
+ {
+ /* Updating postponed, so that accessing the system clipboard won't
+ * hang Vim when accessing it many times (e.g. on a :g comand). */
+ if (cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS))
+ return;
+ else if (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED))
+ return;
+ }
#ifdef FEAT_XCLIPBOARD
# ifdef FEAT_GUI
if (gui.in_use)