patch 9.1.0285: Still problems with cursor position for CTRL-D/U

Problem:  Problems with cursor position when scrolling half a page.
Solution: Rework the cursor logic. (Luuk van Baal)

closes: #14455

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index 5b1bb40..4f99095 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -4225,4 +4225,16 @@
   bw!
 endfunc
 
+" Test for Ctrl-U not getting stuck at end of buffer with 'scrolloff'.
+func Test_halfpage_scrolloff_eob()
+  set scrolloff=5
+
+  call setline(1, range(1, 100))
+  exe "norm! Gzz\<C-U>zz"
+  call assert_notequal(100, line('.'))
+
+  set scrolloff&
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim
index e09c240..cda9bf0 100644
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -1028,10 +1028,10 @@
   call assert_equal(415, col('.'))
   exe "norm! \<C-D>"
   call assert_equal(520, winsaveview().skipcol)
-  call assert_equal(535, col('.'))
+  call assert_equal(615, col('.'))
   exe "norm! \<C-D>"
   call assert_equal(520, winsaveview().skipcol)
-  call assert_equal(735, col('.'))
+  call assert_equal(815, col('.'))
   exe "norm! \<C-D>"
   call assert_equal(520, winsaveview().skipcol)
   call assert_equal(895, col('.'))
@@ -1043,10 +1043,10 @@
   call assert_equal(495, col('.'))
   exe "norm! \<C-U>"
   call assert_equal(0, winsaveview().skipcol)
-  call assert_equal(375, col('.'))
+  call assert_equal(295, col('.'))
   exe "norm! \<C-U>"
   call assert_equal(0, winsaveview().skipcol)
-  call assert_equal(175, col('.'))
+  call assert_equal(95, col('.'))
   exe "norm! \<C-U>"
   call assert_equal(0, winsaveview().skipcol)
   call assert_equal(15, col('.'))