Mercurial > vim
comparison src/screen.c @ 11698:4f59d2a66bf7 v8.0.0732
patch 8.0.0732: when updating a buffer modeless selection is lost
commit https://github.com/vim/vim/commit/80dd3f9d41ce2ff6ab3544cdb266627bbdfc34a6
Author: Bram Moolenaar <Bram@vim.org>
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 19 Jul 2017 13:00:03 +0200 |
parents | 3c6cc2f24645 |
children | 0cfe4a07c2ad |
comparison
equal
deleted
inserted
replaced
11697:4560036348af | 11698:4f59d2a66bf7 |
---|---|
110 #ifdef FEAT_FOLDING | 110 #ifdef FEAT_FOLDING |
111 static foldinfo_T win_foldinfo; /* info for 'foldcolumn' */ | 111 static foldinfo_T win_foldinfo; /* info for 'foldcolumn' */ |
112 static int compute_foldcolumn(win_T *wp, int col); | 112 static int compute_foldcolumn(win_T *wp, int col); |
113 #endif | 113 #endif |
114 | 114 |
115 /* Flag that is set when drawing for a callback, not from the main command | |
116 * loop. */ | |
117 static int redrawing_for_callback = 0; | |
118 | |
115 /* | 119 /* |
116 * Buffer for one screen line (characters and attributes). | 120 * Buffer for one screen line (characters and attributes). |
117 */ | 121 */ |
118 static schar_T *current_ScreenLine; | 122 static schar_T *current_ScreenLine; |
119 | 123 |
443 * it belongs. If highlighting was changed a redraw is needed. | 447 * it belongs. If highlighting was changed a redraw is needed. |
444 */ | 448 */ |
445 void | 449 void |
446 redraw_after_callback(void) | 450 redraw_after_callback(void) |
447 { | 451 { |
452 ++redrawing_for_callback; | |
453 | |
448 if (State == HITRETURN || State == ASKMORE) | 454 if (State == HITRETURN || State == ASKMORE) |
449 ; /* do nothing */ | 455 ; /* do nothing */ |
450 else if (State & CMDLINE) | 456 else if (State & CMDLINE) |
451 { | 457 { |
452 /* Redrawing only works when the screen didn't scroll. Don't clear | 458 /* Redrawing only works when the screen didn't scroll. Don't clear |
477 if (!gui_mch_is_blink_off()) | 483 if (!gui_mch_is_blink_off()) |
478 gui_update_cursor(FALSE, FALSE); | 484 gui_update_cursor(FALSE, FALSE); |
479 gui_mch_flush(); | 485 gui_mch_flush(); |
480 } | 486 } |
481 #endif | 487 #endif |
488 | |
489 --redrawing_for_callback; | |
482 } | 490 } |
483 | 491 |
484 /* | 492 /* |
485 * Changed something in the current window, at buffer line "lnum", that | 493 * Changed something in the current window, at buffer line "lnum", that |
486 * requires that line and possibly other lines to be redrawn. | 494 * requires that line and possibly other lines to be redrawn. |
9740 * FAIL if | 9748 * FAIL if |
9741 * - there is no valid screen | 9749 * - there is no valid screen |
9742 * - the screen has to be redrawn completely | 9750 * - the screen has to be redrawn completely |
9743 * - the line count is less than one | 9751 * - the line count is less than one |
9744 * - the line count is more than 'ttyscroll' | 9752 * - the line count is more than 'ttyscroll' |
9753 * - redrawing for a callback and there is a modeless selection | |
9745 */ | 9754 */ |
9746 if (!screen_valid(TRUE) || line_count <= 0 || line_count > p_ttyscroll) | 9755 if (!screen_valid(TRUE) || line_count <= 0 || line_count > p_ttyscroll |
9756 #ifdef FEAT_CLIPBOARD | |
9757 || (clip_star.state != SELECT_CLEARED | |
9758 && redrawing_for_callback > 0) | |
9759 #endif | |
9760 ) | |
9747 return FAIL; | 9761 return FAIL; |
9748 | 9762 |
9749 /* | 9763 /* |
9750 * There are seven ways to insert lines: | 9764 * There are seven ways to insert lines: |
9751 * 0. When in a vertically split window and t_CV isn't set, redraw the | 9765 * 0. When in a vertically split window and t_CV isn't set, redraw the |
9957 * FAIL if | 9971 * FAIL if |
9958 * - there is no valid screen | 9972 * - there is no valid screen |
9959 * - the screen has to be redrawn completely | 9973 * - the screen has to be redrawn completely |
9960 * - the line count is less than one | 9974 * - the line count is less than one |
9961 * - the line count is more than 'ttyscroll' | 9975 * - the line count is more than 'ttyscroll' |
9976 * - redrawing for a callback and there is a modeless selection | |
9962 */ | 9977 */ |
9963 if (!screen_valid(TRUE) || line_count <= 0 || | 9978 if (!screen_valid(TRUE) || line_count <= 0 |
9964 (!force && line_count > p_ttyscroll)) | 9979 || (!force && line_count > p_ttyscroll) |
9980 #ifdef FEAT_CLIPBOARD | |
9981 || (clip_star.state != SELECT_CLEARED | |
9982 && redrawing_for_callback > 0) | |
9983 #endif | |
9984 ) | |
9965 return FAIL; | 9985 return FAIL; |
9966 | 9986 |
9967 /* | 9987 /* |
9968 * Check if the rest of the current region will become empty. | 9988 * Check if the rest of the current region will become empty. |
9969 */ | 9989 */ |