diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-06-19 09:20:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 09:20:24 +0800 |
commit | b1c439cef6cae54745f3bf446596c1b7e417c80e (patch) | |
tree | 5afb90a872d358ba1307672ebdface70be9e7401 | |
parent | b381b2d529741ddd4f3664959640917a10cd91b5 (diff) | |
download | rneovim-b1c439cef6cae54745f3bf446596c1b7e417c80e.tar.gz rneovim-b1c439cef6cae54745f3bf446596c1b7e417c80e.tar.bz2 rneovim-b1c439cef6cae54745f3bf446596c1b7e417c80e.zip |
fix(drawline): don't draw beyond end of window with 'rnu' (#29406)
-rw-r--r-- | src/nvim/drawline.c | 2 | ||||
-rw-r--r-- | test/functional/ui/diff_spec.lua | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 6109652f7d..579b237af6 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1553,7 +1553,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s // When only updating the columns and that's done, stop here. if (col_rows > 0) { - wlv_put_linebuf(wp, &wlv, wlv.off, false, bg_attr, 0); + wlv_put_linebuf(wp, &wlv, MIN(wlv.off, grid->cols), false, bg_attr, 0); // Need to update more screen lines if: // - 'statuscolumn' needs to be drawn, or // - LineNrAbove or LineNrBelow is used, or diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index e79621f364..bad35dd2af 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -1346,6 +1346,46 @@ it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function() eq('0', api.nvim_get_option_value('foldcolumn', {})) end) +it("'relativenumber' doesn't draw beyond end of window in diff mode #29403", function() + local screen = Screen.new(60, 12) + screen:attach() + command('set relativenumber') + feed('10aa<CR><Esc>gg') + command('vnew') + feed('ab<CR><Esc>gg') + command('windo diffthis') + command('wincmd |') + screen:expect([[ + {8: }│{7: }{8: 0 }{27:^a}{4: }| + {8: }│{7: }{8: 1 }{22:a }| + {8: }│{7: }{8: 2 }{22:a }| + {8: }│{7: }{8: 3 }{22:a }| + {8: }│{7: }{8: 4 }{22:a }| + {8: }│{7: }{8: 5 }{22:a }| + {8: }│{7: }{8: 6 }{22:a }| + {8: }│{7: }{8: 7 }{22:a }| + {8: }│{7: }{8: 8 }{22:a }| + {8: }│{7: }{8: 9 }{22:a }| + {2:< }{3:[No Name] [+] }| + | + ]]) + feed('j') + screen:expect([[ + {8: }│{7: }{8: 1 }{27:a}{4: }| + {8: }│{7: }{8: 0 }{22:^a }| + {8: }│{7: }{8: 1 }{22:a }| + {8: }│{7: }{8: 2 }{22:a }| + {8: }│{7: }{8: 3 }{22:a }| + {8: }│{7: }{8: 4 }{22:a }| + {8: }│{7: }{8: 5 }{22:a }| + {8: }│{7: }{8: 6 }{22:a }| + {8: }│{7: }{8: 7 }{22:a }| + {8: }│{7: }{8: 8 }{22:a }| + {2:< }{3:[No Name] [+] }| + | + ]]) +end) + -- oldtest: Test_diff_binary() it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function() local screen = Screen.new(40, 20) |