diff src/normal.c @ 34761:b20609f4ab37 v9.1.0258

patch 9.1.0258: half-page scrolling broke backward compatibility Commit: https://github.com/vim/vim/commit/cb204e688e5c9d56a78b621ef27c35d91860cb09 Author: Luuk van Baal <luukvbaal@gmail.com> Date: Tue Apr 2 20:49:45 2024 +0200 patch 9.1.0258: half-page scrolling broke backward compatibility Problem: Support for 'smoothscroll' in (half-)page scrolling broke backward compatibility and can be made to work better. (after v9.1.215) Solution: Restore the previous cursor and end-of-buffer behavior for half-page scrolling and improve 'smoothscroll' support. (Luuk van Baal) fixes: #14338 closes: #14377 Signed-off-by: Luuk van Baal <luukvbaal@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 02 Apr 2024 21:00:06 +0200
parents ca2da8e8fb53
children 8e38ceda0822
line wrap: on
line diff
--- a/src/normal.c
+++ b/src/normal.c
@@ -2303,7 +2303,7 @@ find_decl(
  *
  * Return OK if able to move cursor, FAIL otherwise.
  */
-    static int
+    int
 nv_screengo(oparg_T *oap, int dir, long dist)
 {
 
@@ -5745,7 +5745,7 @@ nv_gv_cmd(cmdarg_T *cap)
  * "g0", "g^" : Like "0" and "^" but for screen lines.
  * "gm": middle of "g0" and "g$".
  */
-    static void
+    void
 nv_g_home_m_cmd(cmdarg_T *cap)
 {
     int		i;
@@ -5771,6 +5771,15 @@ nv_g_home_m_cmd(cmdarg_T *cap)
 	i = 0;
 	if (virtcol >= (colnr_T)width1 && width2 > 0)
 	    i = (virtcol - width1) / width2 * width2 + width1;
+
+	// When ending up below 'smoothscroll' marker, move just beyond it so
+	// that skipcol is not adjusted later.
+	if (curwin->w_skipcol > 0 && curwin->w_cursor.lnum == curwin->w_topline)
+	{
+	    int overlap = sms_marker_overlap(curwin, -1);
+	    if (overlap > 0 && i == curwin->w_skipcol)
+		i += overlap;
+	}
     }
     else
 	i = curwin->w_leftcol;
@@ -7263,8 +7272,9 @@ nv_at(cmdarg_T *cap)
     static void
 nv_halfpage(cmdarg_T *cap)
 {
+    int	dir = cap->cmdchar == Ctrl_D ? FORWARD : BACKWARD;
     if (!checkclearop(cap->oap))
-	pagescroll(cap->cmdchar == Ctrl_D, cap->count0, TRUE);
+	pagescroll(dir, cap->count0, TRUE);
 }
 
 /*