patch 9.1.1482: scrolling with 'splitkeep' and line()

Problem:  Topline is preemptively updated by line() in WinResized
          autocmd with 'splitkeep' != "cursor".
Solution: Set `skip_update_topline` when 'splitkeep' != "cursor".
          (Luuk van Baal)

related: neovim/neovim#34666
closes: #17613

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 76955a7..2e864f7 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -8833,19 +8833,18 @@
 	{
 	    if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
 	    {
+		// With 'splitkeep' != cursor and in diff mode, prevent that the
+		// window scrolls and keep the topline.
+		if (*p_spk != 'c'
 #ifdef FEAT_DIFF
-		// in diff mode, prevent that the window scrolls
-		// and keep the topline
-		if (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff)
-		    skip_update_topline = TRUE;
+		|| (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff)
 #endif
+		)
+		    skip_update_topline = TRUE;
 		check_cursor();
 		fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);
 	    }
-#ifdef FEAT_DIFF
-	    if (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff)
-		skip_update_topline = FALSE;
-#endif
+	    skip_update_topline = FALSE;
 	    restore_win_noblock(&switchwin, TRUE);
 	}
     }
diff --git a/src/testdir/dumps/Test_splitkeep_line_1.dump b/src/testdir/dumps/Test_splitkeep_line_1.dump
new file mode 100644
index 0000000..7a387ba
--- /dev/null
+++ b/src/testdir/dumps/Test_splitkeep_line_1.dump
@@ -0,0 +1,6 @@
+>0+0&#ffffff0| @38
+|1| @38
+|2| @38
+|3| @38
+|4| @38
+@22|1|,|1| @10|T|o|p| 
diff --git a/src/testdir/dumps/Test_splitkeep_line_2.dump b/src/testdir/dumps/Test_splitkeep_line_2.dump
new file mode 100644
index 0000000..c322f1d
--- /dev/null
+++ b/src/testdir/dumps/Test_splitkeep_line_2.dump
@@ -0,0 +1,6 @@
+>0+0&#ffffff0| @38
+|1| @38
+|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @8|1|,|1| @11|T|o|p
+|3+0&&| @38
+|[+1&&|N|o| |N|a|m|e|]| |[|+|]| @8|1|,|1| @12|0|%
+|:+0&&|w|i|n|c|m|d| |s| @30
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index c5edb0d..4e02f00 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -2120,6 +2120,24 @@
   call VerifyScreenDump(buf, 'Test_splitkeep_skipcol_1', {})
 endfunc
 
+func Test_splitkeep_line()
+  CheckScreendump
+
+  let lines =<< trim END
+    set splitkeep=screen nosplitbelow
+    autocmd WinResized * call line('w0', 1000)
+    call setline(1, range(1000))
+  END
+
+  call writefile(lines, 'XTestSplitkeepSkipcol', 'D')
+  let buf = RunVimInTerminal('-S XTestSplitkeepSkipcol', #{rows: 6, cols: 40})
+
+  call VerifyScreenDump(buf, 'Test_splitkeep_line_1', {})
+
+  call term_sendkeys(buf, ":wincmd s\<CR>")
+  call VerifyScreenDump(buf, 'Test_splitkeep_line_2', {})
+endfunc
+
 func Test_new_help_window_on_error()
   help change.txt
   execute "normal! /CTRL-@\<CR>"
diff --git a/src/version.c b/src/version.c
index c7c66ec..67346ec 100644
--- a/src/version.c
+++ b/src/version.c
@@ -710,6 +710,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1482,
+/**/
     1481,
 /**/
     1480,