diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-10-17 04:24:23 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-10-17 01:24:23 -0700 |
commit | 0785f8e8b11b2fa290cfbc0604d570f49b954ba6 (patch) | |
tree | ec9cd655c7a85a533d03240965df22c16f6dce23 /src/nvim/normal.c | |
parent | 94bda2fec8d03cdbea442d70c41186f0aa039786 (diff) | |
download | rneovim-0785f8e8b11b2fa290cfbc0604d570f49b954ba6.tar.gz rneovim-0785f8e8b11b2fa290cfbc0604d570f49b954ba6.tar.bz2 rneovim-0785f8e8b11b2fa290cfbc0604d570f49b954ba6.zip |
vim-patch:8.1.2140: "gk" and "gj" do not work correctly in number column #11208
Problem: "gk" and "gj" do not work correctly in number column.
Solution: Allow for a negative "curswant". (Zach Wegner, closes vim/vim#4969)
https://github.com/vim/vim/commit/ceba3dd5187788e09f65bd41b07b40f6f9aab953
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index e0dc9d4f23..d051ba33b8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3925,15 +3925,17 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; else n = width1; - if (curwin->w_curswant > (colnr_T)n + 1) - curwin->w_curswant -= ((curwin->w_curswant - n) / width2 + 1) - * width2; + if (curwin->w_curswant >= n) { + curwin->w_curswant = n - 1; + } } while (dist--) { if (dir == BACKWARD) { - if (curwin->w_curswant > width2) { - // move back within line + if (curwin->w_curswant >= width1) { + // Move back within the line. This can give a negative value + // for w_curswant if width1 < width2 (with cpoptions+=n), + // which will get clipped to column 0. curwin->w_curswant -= width2; } else { // to previous line @@ -3973,6 +3975,13 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) } curwin->w_cursor.lnum++; curwin->w_curswant %= width2; + // Check if the cursor has moved below the number display + // when width1 < width2 (with cpoptions+=n). Subtract width2 + // to get a negative value for w_curswant, which will get + // clipped to column 0. + if (curwin->w_curswant >= width1) { + curwin->w_curswant -= width2; + } linelen = linetabsize(get_cursor_line_ptr()); } } |