# HG changeset patch # User Christian Brabandt # Date 1500462003 -7200 # Node ID 4f59d2a66bf7b69656bd8f135d71933703953d10 # Parent 4560036348af78261114fdbdf3c9d9d78d4f9c8d patch 8.0.0732: when updating a buffer modeless selection is lost commit https://github.com/vim/vim/commit/80dd3f9d41ce2ff6ab3544cdb266627bbdfc34a6 Author: Bram Moolenaar Date: Wed Jul 19 12:51:52 2017 +0200 patch 8.0.0732: when updating a buffer modeless selection is lost 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. diff --git a/src/screen.c b/src/screen.c --- a/src/screen.c +++ b/src/screen.c @@ -112,6 +112,10 @@ static foldinfo_T win_foldinfo; /* info 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; /* diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 732, +/**/ 731, /**/ 730,