aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-09-27 06:33:48 +0800
committerGitHub <noreply@github.com>2022-09-27 06:33:48 +0800
commit7e98821e56a88487f24584463869432d8373a28e (patch)
tree66644293b3a206014cc3b976fdec1fc6d346fae5
parent9a5ac065093b58cceb676700b988584931cef150 (diff)
downloadrneovim-7e98821e56a88487f24584463869432d8373a28e.tar.gz
rneovim-7e98821e56a88487f24584463869432d8373a28e.tar.bz2
rneovim-7e98821e56a88487f24584463869432d8373a28e.zip
fix(ui): redraw end of buffer if last line is modified (#20354)
-rw-r--r--src/nvim/drawscreen.c3
-rw-r--r--test/functional/ui/decorations_spec.lua104
2 files changed, 106 insertions, 1 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index c95f3f3550..fdf70a081c 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -1965,7 +1965,8 @@ win_update_start:
if (mid_end >= row) {
lastline = MIN(lastline, mid_start);
}
- if (mod_bot > buf->b_ml.ml_line_count + 1) {
+ // if (mod_bot > buf->b_ml.ml_line_count + 1) {
+ if (mod_bot > buf->b_ml.ml_line_count) {
lastline = 0;
}
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index eff6fe6d23..9b48f0ac35 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -1281,6 +1281,110 @@ if (h->n_buckets < new_n_buckets) { // expand
]]}
end)
+ it('works beyond end of the buffer with virt_lines_above', function()
+ insert(example_text)
+ feed 'G'
+
+ screen:expect{grid=[[
+ if (h->n_buckets < new_n_buckets) { // expand |
+ khkey_t *new_keys = (khkey_t *)krealloc((void *)|
+ h->keys, new_n_buckets * sizeof(khkey_t)); |
+ h->keys = new_keys; |
+ if (kh_is_map && val_size) { |
+ char *new_vals = krealloc( h->vals_buf, new_n_|
+ buckets * val_size); |
+ h->vals_buf = new_vals; |
+ } |
+ ^} |
+ {1:~ }|
+ |
+ ]]}
+
+ local id = meths.buf_set_extmark(0, ns, 8, 0, {
+ virt_lines={{{"Grugg"}}};
+ virt_lines_above = true,
+ })
+
+ screen:expect{grid=[[
+ if (h->n_buckets < new_n_buckets) { // expand |
+ khkey_t *new_keys = (khkey_t *)krealloc((void *)|
+ h->keys, new_n_buckets * sizeof(khkey_t)); |
+ h->keys = new_keys; |
+ if (kh_is_map && val_size) { |
+ char *new_vals = krealloc( h->vals_buf, new_n_|
+ buckets * val_size); |
+ h->vals_buf = new_vals; |
+ } |
+ ^} |
+ Grugg |
+ |
+ ]]}
+
+ feed('dd')
+ screen:expect{grid=[[
+ if (h->n_buckets < new_n_buckets) { // expand |
+ khkey_t *new_keys = (khkey_t *)krealloc((void *)|
+ h->keys, new_n_buckets * sizeof(khkey_t)); |
+ h->keys = new_keys; |
+ if (kh_is_map && val_size) { |
+ char *new_vals = krealloc( h->vals_buf, new_n_|
+ buckets * val_size); |
+ h->vals_buf = new_vals; |
+ ^} |
+ Grugg |
+ {1:~ }|
+ |
+ ]]}
+
+ feed('dk')
+ screen:expect{grid=[[
+ if (h->n_buckets < new_n_buckets) { // expand |
+ khkey_t *new_keys = (khkey_t *)krealloc((void *)|
+ h->keys, new_n_buckets * sizeof(khkey_t)); |
+ h->keys = new_keys; |
+ if (kh_is_map && val_size) { |
+ ^char *new_vals = krealloc( h->vals_buf, new_n_|
+ buckets * val_size); |
+ Grugg |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+
+ feed('dgg')
+ screen:expect{grid=[[
+ ^ |
+ Grugg |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ --No lines in buffer-- |
+ ]]}
+
+ meths.buf_del_extmark(0, ns, id)
+ screen:expect{grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ --No lines in buffer-- |
+ ]]}
+ end)
+
it('does not cause syntax ml_get error at the end of a buffer #17816', function()
command([[syntax region foo keepend start='^foo' end='^$']])
command('syntax sync minlines=100')