aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-04-27 00:57:48 +0200
committerLuuk van Baal <luukvbaal@gmail.com>2023-05-02 13:11:47 +0200
commit6146400605af93ac48dae4393569c44e8a2e39d2 (patch)
tree643008b5e4fdfff3b10dfa6eac1c069d042386fd
parentc426f7a6228cb82af0f75ac4f2421543408ff091 (diff)
downloadrneovim-6146400605af93ac48dae4393569c44e8a2e39d2.tar.gz
rneovim-6146400605af93ac48dae4393569c44e8a2e39d2.tar.bz2
rneovim-6146400605af93ac48dae4393569c44e8a2e39d2.zip
vim-patch:9.0.0757: line number not visisble with 'smoothscroll', 'nu' and 'rnu'
Problem: Line number not visisble with 'smoothscroll', 'nu' and 'rnu'. Solution: Put the ">>>" after the line number instead of on top. https://github.com/vim/vim/commit/eb4de629315f2682d8b314462d02422ec98d751a Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/drawline.c2
-rw-r--r--src/nvim/grid.c18
-rw-r--r--test/functional/legacy/scroll_opt_spec.lua21
-rw-r--r--test/old/testdir/test_scroll_opt.vim14
4 files changed, 51 insertions, 4 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 0d701f07bb..ef9912e503 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -609,7 +609,7 @@ static void handle_lnum_col(win_T *wp, winlinevars_T *wlv, int num_signs, int si
} else {
// Draw the line number (empty space after wrapping).
if (wlv->row == wlv->startrow + wlv->filler_lines
- && (wp->w_skipcol == 0 || wlv->row > wp->w_winrow)) {
+ && (wp->w_skipcol == 0 || wlv->row > wp->w_winrow || (wp->w_p_nu && wp->w_p_rnu))) {
get_line_number_str(wp, wlv->lnum, wlv->extra, sizeof(wlv->extra));
if (wp->w_skipcol > 0 && wlv->startrow == 0) {
for (wlv->p_extra = wlv->extra; *wlv->p_extra == ' '; wlv->p_extra++) {
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index 0ceaeaa8b2..8431c078b9 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -533,9 +533,21 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle
if (topline && wp->w_skipcol > 0 && *get_showbreak_value(wp) == NUL) {
// Take care of putting "<<<" on the first line for 'smoothscroll'
// when 'showbreak' is not set.
- for (int i = 0; i < 3; i++) {
- schar_from_ascii(linebuf_char[i], '<');
- linebuf_attr[i] = HL_ATTR(HLF_AT);
+ int off = 0;
+ int skip = 0;
+ if (wp->w_p_nu && wp->w_p_rnu) {
+ // do not overwrite the line number, change "123 text" to
+ // "123>>>xt".
+ while (skip < wp->w_width && ascii_isdigit(*linebuf_char[off])) {
+ off++;
+ skip++;
+ }
+ }
+
+ for (int i = 0; i < 3 && i + skip < wp->w_width; i++) {
+ schar_from_ascii(linebuf_char[off], '<');
+ linebuf_attr[off] = HL_ATTR(HLF_AT);
+ off++;
}
}
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua
index a5660ae4d2..5e54470bd4 100644
--- a/test/functional/legacy/scroll_opt_spec.lua
+++ b/test/functional/legacy/scroll_opt_spec.lua
@@ -181,6 +181,12 @@ describe('smoothscroll', function()
set smoothscroll scrolloff=5
set number cpo+=n
:3
+ func g:DoRel()
+ set number relativenumber scrolloff=0
+ :%del
+ call setline(1, [ 'one', 'very long text '->repeat(12), 'three', ])
+ exe "normal 2Gzt\<C-E>"
+ endfunc
]])
screen:expect([[
1 one word word word word word word wo|
@@ -271,6 +277,21 @@ describe('smoothscroll', function()
~ |
|
]])
+ exec('call DoRel()')
+ screen:expect([[
+ 2<<<ong text very long text very lon^g te|
+ xt very long text very long text ver|
+ y long text very long text very long|
+ text very long text very long text |
+ 1 three |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ --No lines in buffer-- |
+ ]])
end)
-- oldtest: Test_smoothscroll_diff_mode()
diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim
index a8e0a1109a..c394c6adf8 100644
--- a/test/old/testdir/test_scroll_opt.vim
+++ b/test/old/testdir/test_scroll_opt.vim
@@ -138,6 +138,17 @@ func Test_smoothscroll_number()
set smoothscroll
set number cpo+=n
:3
+
+ def g:DoRel()
+ set number relativenumber scrolloff=0
+ :%del
+ setline(1, [
+ 'one',
+ 'very long text '->repeat(12),
+ 'three',
+ ])
+ exe "normal 2Gzt\<C-E>"
+ enddef
END
call writefile(lines, 'XSmoothNumber', 'D')
let buf = RunVimInTerminal('-S XSmoothNumber', #{rows: 12, cols: 40})
@@ -155,6 +166,9 @@ func Test_smoothscroll_number()
call term_sendkeys(buf, "\<C-Y>")
call VerifyScreenDump(buf, 'Test_smooth_number_6', {})
+ call term_sendkeys(buf, ":call DoRel()\<CR>")
+ call VerifyScreenDump(buf, 'Test_smooth_number_7', {})
+
call StopVimInTerminal(buf)
endfunc