diff --git a/src/nvim/change.c b/src/nvim/change.c index 4c9633a938..ff6a25eaa8 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -243,9 +243,17 @@ static void changed_common(buf_T *buf, linenr_T lnum, colnr_T col, linenr_T lnum changed(buf); FOR_ALL_WINDOWS_IN_TAB(win, curtab) { - if (win->w_buffer == buf && win->w_p_diff && diff_internal()) { - curtab->tp_diff_update = true; - diff_update_line(lnum); + if (win->w_buffer == buf) { + if (win->w_p_diff && diff_internal()) { + curtab->tp_diff_update = true; + diff_update_line(lnum); + } + + // Redraw status when line count changes to prevent 'statusline' or + // 'rulerformat' items becoming invalid. + if (xtra != 0) { + win->w_redr_status = true; + } } } diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua index 74d5b40790..978fd921ce 100644 --- a/test/functional/terminal/window_spec.lua +++ b/test/functional/terminal/window_spec.lua @@ -361,7 +361,7 @@ describe(':terminal window', function() rows: 5, cols: 25 │rows: 5, cols: 25 | ^ │ | │ |*2 - {120: 0) eq(caller_win, contexts[#contexts].actual) end) + + it('%P %L updates in other windows', function() + screen:try_resize(40, 14) + command('set laststatus=2 statusline=%P\\ %L | split') + feed(':put=range(10)dgg') + screen:expect([[ + ^ | + {1:~ }|*5 + {3:All 1 }| + | + {1:~ }|*4 + {2:All 1 }| + --No lines in buffer-- | + ]]) + end) end) describe('default statusline', function()