]> granicus.if.org Git - vim/commitdiff
patch 8.0.0732: when updating a buffer modeless selection is lost v8.0.0732
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Jul 2017 10:51:52 +0000 (12:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Jul 2017 10:51:52 +0000 (12:51 +0200)
Problem:    When updating a buffer for a callback the modeless selection is
            lost.
Solution:   Do not insert or delete screen lines when redrawing for a callback
            and there is a modeless selection.

src/screen.c
src/version.c

index 0ec9ea28166a6ede0696bb463f2450d1b0bc232d..447eb1e49b4c0c63340a2d907f52e36328d41f50 100644 (file)
@@ -112,6 +112,10 @@ static foldinfo_T win_foldinfo;    /* info for 'foldcolumn' */
 static int compute_foldcolumn(win_T *wp, int col);
 #endif
 
+/* Flag that is set when drawing for a callback, not from the main command
+ * loop. */
+static int redrawing_for_callback = 0;
+
 /*
  * Buffer for one screen line (characters and attributes).
  */
@@ -445,6 +449,8 @@ redraw_asap(int type)
     void
 redraw_after_callback(void)
 {
+    ++redrawing_for_callback;
+
     if (State == HITRETURN || State == ASKMORE)
        ; /* do nothing */
     else if (State & CMDLINE)
@@ -479,6 +485,8 @@ redraw_after_callback(void)
        gui_mch_flush();
     }
 #endif
+
+    --redrawing_for_callback;
 }
 
 /*
@@ -9742,8 +9750,14 @@ screen_ins_lines(
      * - the screen has to be redrawn completely
      * - the line count is less than one
      * - the line count is more than 'ttyscroll'
+     * - redrawing for a callback and there is a modeless selection
      */
-    if (!screen_valid(TRUE) || line_count <= 0 || line_count > p_ttyscroll)
+     if (!screen_valid(TRUE) || line_count <= 0 || line_count > p_ttyscroll
+#ifdef FEAT_CLIPBOARD
+            || (clip_star.state != SELECT_CLEARED
+                                                && redrawing_for_callback > 0)
+#endif
+            )
        return FAIL;
 
     /*
@@ -9959,9 +9973,15 @@ screen_del_lines(
      * - the screen has to be redrawn completely
      * - the line count is less than one
      * - the line count is more than 'ttyscroll'
+     * - redrawing for a callback and there is a modeless selection
      */
-    if (!screen_valid(TRUE) || line_count <= 0 ||
-                                        (!force && line_count > p_ttyscroll))
+    if (!screen_valid(TRUE) || line_count <= 0
+                                       || (!force && line_count > p_ttyscroll)
+#ifdef FEAT_CLIPBOARD
+            || (clip_star.state != SELECT_CLEARED
+                                                && redrawing_for_callback > 0)
+#endif
+       )
        return FAIL;
 
     /*
index 9c94fe8f84cb26b46ae6817017a165a964ae2aca..8c4923cc074080e55dcc60fe3b8594c19442d6f1 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    732,
 /**/
     731,
 /**/