aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/normal.c8
-rw-r--r--src/nvim/testdir/test_normal.vim22
2 files changed, 26 insertions, 4 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 4dfde96e94..d4065cc06e 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -3932,11 +3932,11 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
while (dist--) {
if (dir == BACKWARD) {
- if ((long)curwin->w_curswant >= width2)
- /* move back within line */
+ if (curwin->w_curswant > width2) {
+ // move back within line
curwin->w_curswant -= width2;
- else {
- /* to previous line */
+ } else {
+ // to previous line
if (curwin->w_cursor.lnum == 1) {
retval = false;
break;
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index 532beb9c39..5ff2cf66c9 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -2617,3 +2617,25 @@ Piece of Java
close!
endfunc
+
+func Test_normal_gk()
+ " needs 80 column new window
+ new
+ vert 80new
+ put =[repeat('x',90)..' {{{1', 'x {{{1']
+ norm! gk
+ " In a 80 column wide terminal the window will be only 78 char
+ " (because Vim will leave space for the other window),
+ " but if the terminal is larger, it will be 80 chars, so verify the
+ " cursor column correctly.
+ call assert_equal(winwidth(0)+1, col('.'))
+ call assert_equal(winwidth(0)+1, virtcol('.'))
+ norm! j
+ call assert_equal(6, col('.'))
+ call assert_equal(6, virtcol('.'))
+ norm! gk
+ call assert_equal(95, col('.'))
+ call assert_equal(95, virtcol('.'))
+ bw!
+ bw!
+endfunc