aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-06-26 19:42:57 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2019-07-05 16:58:53 +0200
commit51a451570df5fe3775a09324fb2247bfa4cf48d9 (patch)
tree77441850b697e0566e91bd91d62901f2e9802104
parent0d82aaf5866b954ab0fe4831df499a4713eeae35 (diff)
downloadrneovim-51a451570df5fe3775a09324fb2247bfa4cf48d9.tar.gz
rneovim-51a451570df5fe3775a09324fb2247bfa4cf48d9.tar.bz2
rneovim-51a451570df5fe3775a09324fb2247bfa4cf48d9.zip
screen: disable redrawing inside VimResized
Note: test doesn't fail on master. I cannot reproduce the glitches with -u NONE, probably it requires interfering events. But add some coverage for these checks at least.
-rw-r--r--src/nvim/screen.c30
-rw-r--r--test/functional/ui/popupmenu_spec.lua44
2 files changed, 61 insertions, 13 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 4ea196fa44..acff44164f 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -153,6 +153,8 @@ static bool conceal_cursor_used = false;
static bool redraw_popupmenu = false;
+static bool resizing = false;
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "screen.c.generated.h"
#endif
@@ -275,7 +277,9 @@ int update_screen(int type)
int did_one;
// Don't do anything if the screen structures are (not yet) valid.
- if (!default_grid.chars) {
+ // A VimResized autocmd can invoke redrawing in the middle of a resize,
+ // which would bypass the checks in screen_resize for popupmenu etc.
+ if (!default_grid.chars || resizing) {
return FAIL;
}
@@ -5989,7 +5993,14 @@ void grid_assign_handle(ScreenGrid *grid)
/// needed.
void screenalloc(void)
{
- static bool entered = false; // avoid recursiveness
+ // It's possible that we produce an out-of-memory message below, which
+ // will cause this function to be called again. To break the loop, just
+ // return here.
+ if (resizing) {
+ return;
+ }
+ resizing = true;
+
int retry_count = 0;
retry:
@@ -6003,19 +6014,11 @@ retry:
|| Rows == 0
|| Columns == 0
|| (!full_screen && default_grid.chars == NULL)) {
+ resizing = false;
return;
}
/*
- * It's possible that we produce an out-of-memory message below, which
- * will cause this function to be called again. To break the loop, just
- * return here.
- */
- if (entered)
- return;
- entered = TRUE;
-
- /*
* Note that the window sizes are updated before reallocating the arrays,
* thus we must not redraw here!
*/
@@ -6055,8 +6058,7 @@ retry:
must_redraw = CLEAR; // need to clear the screen later
- entered = FALSE;
- --RedrawingDisabled;
+ RedrawingDisabled--;
/*
* Do not apply autocommands more than 3 times to avoid an endless loop
@@ -6068,6 +6070,8 @@ retry:
* jump back to check if we need to allocate the screen again. */
goto retry;
}
+
+ resizing = false;
}
void grid_alloc(ScreenGrid *grid, int rows, int columns, bool copy, bool valid)
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index ffa803e7e1..9bfea28ed7 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -1152,6 +1152,50 @@ describe('builtin popupmenu', function()
]])
end)
+ it('behaves correcty with VimResized autocmd', function()
+ feed('isome long prefix before the ')
+ command("set completeopt+=noinsert,noselect")
+ command("autocmd VimResized * redraw!")
+ command("set linebreak")
+ funcs.complete(29, {'word', 'choice', 'text', 'thing'})
+ screen:expect([[
+ some long prefix before the ^ |
+ {1:~ }{n: word }|
+ {1:~ }{n: choice}|
+ {1:~ }{n: text }|
+ {1:~ }{n: thing }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- INSERT --} |
+ ]])
+
+ screen:try_resize(16,10)
+ screen:expect([[
+ some long |
+ prefix before |
+ the ^ |
+ {1:~ }{n: word }|
+ {1:~ }{n: choice }|
+ {1:~ }{n: text }|
+ {1:~ }{n: thing }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- INSERT --} |
+ ]])
+ end)
+
it('works with rightleft window', function()
command("set rl")
feed('isome rightleft ')