To: vim_dev@googlegroups.com Subject: Patch 9.0.1525 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1525 Problem: 'smoothscroll' does not always work properly. Solution: Do not reset w_skipcol after it was intentionally set. (Luuk van Baal, closes #12360, closes #12199, closes #12323) Files: src/move.c, src/testdir/dumps/Test_smooth_cursormoved_line.dump, src/testdir/dumps/Test_smooth_eob_1.dump, src/testdir/dumps/Test_smooth_eob_2.dump, src/testdir/dumps/Test_smooth_long_10.dump, src/testdir/test_scroll_opt.vim *** ../vim-9.0.1524/src/move.c 2023-05-06 12:39:58.736971487 +0100 --- src/move.c 2023-05-08 15:47:42.022648371 +0100 *************** *** 276,285 **** long line_count; int halfheight; int n; - linenr_T old_topline; - #ifdef FEAT_DIFF - int old_topfill; - #endif #ifdef FEAT_FOLDING linenr_T lnum; #endif --- 276,281 ---- *************** *** 311,319 **** if (mouse_dragging > 0) *so_ptr = mouse_dragging - 1; ! old_topline = curwin->w_topline; #ifdef FEAT_DIFF ! old_topfill = curwin->w_topfill; #endif /* --- 307,316 ---- if (mouse_dragging > 0) *so_ptr = mouse_dragging - 1; ! linenr_T old_topline = curwin->w_topline; ! colnr_T old_skipcol = curwin->w_skipcol; #ifdef FEAT_DIFF ! int old_topfill = curwin->w_topfill; #endif /* *************** *** 516,522 **** { dollar_vcol = -1; redraw_later(UPD_VALID); ! reset_skipcol(); // May need to set w_skipcol when cursor in w_topline. if (curwin->w_cursor.lnum == curwin->w_topline) --- 513,522 ---- { dollar_vcol = -1; redraw_later(UPD_VALID); ! ! // Only reset w_skipcol if it was not just set to make cursor visible. ! if (curwin->w_skipcol == old_skipcol) ! reset_skipcol(); // May need to set w_skipcol when cursor in w_topline. if (curwin->w_cursor.lnum == curwin->w_topline) *************** *** 2769,2775 **** int above = 0; linenr_T topline; colnr_T skipcol = 0; - int set_skipcol = FALSE; #ifdef FEAT_DIFF int topfill = 0; #endif --- 2769,2774 ---- *************** *** 2798,2811 **** #endif topline = loff.lnum; ! int half_height = 0; int smooth_scroll = FALSE; if (curwin->w_p_sms && curwin->w_p_wrap) { // 'smoothscroll' and 'wrap' are set smooth_scroll = TRUE; ! half_height = (curwin->w_height - used) / 2; ! used = 0; } while (topline > 1) --- 2797,2815 ---- #endif topline = loff.lnum; ! int want_height; int smooth_scroll = FALSE; if (curwin->w_p_sms && curwin->w_p_wrap) { // 'smoothscroll' and 'wrap' are set smooth_scroll = TRUE; ! if (atend) ! { ! want_height = (curwin->w_height - used) / 2; ! used = 0; ! } ! else ! want_height = curwin->w_height; } while (topline > 1) *************** *** 2817,2838 **** topline_back_winheight(&loff, FALSE); if (loff.height == MAXCOL) break; ! else ! used += loff.height; ! if (used > half_height) { ! if (used - loff.height < half_height) { - int plines_offset = used - half_height; - loff.height -= plines_offset; - used = half_height; - topline = loff.lnum; #ifdef FEAT_DIFF topfill = loff.fill; #endif ! skipcol = skipcol_from_plines(curwin, plines_offset); ! set_skipcol = TRUE; } break; } --- 2821,2841 ---- topline_back_winheight(&loff, FALSE); if (loff.height == MAXCOL) break; ! used += loff.height; ! if (!atend && boff.lnum < curbuf->b_ml.ml_line_count) ! { ! botline_forw(&boff); ! used += boff.height; ! } ! if (used > want_height) { ! if (used - loff.height < want_height) { topline = loff.lnum; #ifdef FEAT_DIFF topfill = loff.fill; #endif ! skipcol = skipcol_from_plines(curwin, used - want_height); } break; } *************** *** 2906,2916 **** #endif { if (curwin->w_topline != topline ! || set_skipcol || curwin->w_skipcol != 0) { curwin->w_topline = topline; ! if (set_skipcol) { curwin->w_skipcol = skipcol; redraw_later(UPD_NOT_VALID); --- 2909,2919 ---- #endif { if (curwin->w_topline != topline ! || skipcol != 0 || curwin->w_skipcol != 0) { curwin->w_topline = topline; ! if (skipcol != 0) { curwin->w_skipcol = skipcol; redraw_later(UPD_NOT_VALID); *** ../vim-9.0.1524/src/testdir/dumps/Test_smooth_cursormoved_line.dump 2023-05-08 15:50:30.362296214 +0100 --- src/testdir/dumps/Test_smooth_cursormoved_line.dump 2023-05-08 15:45:33.926975686 +0100 *************** *** 0 **** --- 1,6 ---- + |<+0#4040ff13#ffffff0@2|_+0#0000000&@71 + @75 + @73>x@1 + @1|_@72|x + @2| @72 + @57|3|,|7|4| @9|B|o|t| *** ../vim-9.0.1524/src/testdir/dumps/Test_smooth_eob_1.dump 2023-05-08 15:50:30.366296208 +0100 --- src/testdir/dumps/Test_smooth_eob_1.dump 2023-05-08 15:45:33.926975686 +0100 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + @75 + @75 + @75 + @75 + @75 + @75 + @75 + > @74 + @57|1|0@1|,|0|-|1| @6|B|o|t| *** ../vim-9.0.1524/src/testdir/dumps/Test_smooth_eob_2.dump 2023-05-08 15:50:30.370296198 +0100 --- src/testdir/dumps/Test_smooth_eob_2.dump 2023-05-08 15:45:33.926975686 +0100 *************** *** 0 **** --- 1,10 ---- + |<+0#4040ff13#ffffff0@2|a+0#0000000&@21| @49 + @75 + @75 + @75 + @75 + @75 + @75 + @75 + > @74 + @57|1|0@1|,|0|-|1| @6|B|o|t| *** ../vim-9.0.1524/src/testdir/dumps/Test_smooth_long_10.dump 2022-12-31 15:12:58.046637322 +0000 --- src/testdir/dumps/Test_smooth_long_10.dump 2023-05-08 15:45:33.926975686 +0100 *************** *** 1,6 **** ! |<+0#4040ff13#ffffff0@2|o+0#0000000&|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o |f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |e|n|d| @11 >f|o|u|r| @35 ! |~+0#4040ff13&| @38 ! |~| @38 ! |:+0#0000000&|s|e|t| |s|c|r|o|l@1|o| @9|4|,|1| @10|B|o|t| --- 1,6 ---- ! |<+0#4040ff13#ffffff0@2|t+0#0000000&|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t ! |h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o ! |t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o |f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |e|n|d| @11 >f|o|u|r| @35 ! |:|s|e|t| |s|c|r|o|l@1|o| @9|4|,|1| @10|B|o|t| *** ../vim-9.0.1524/src/testdir/test_scroll_opt.vim 2023-05-06 13:01:24.394980077 +0100 --- src/testdir/test_scroll_opt.vim 2023-05-08 15:45:33.930975675 +0100 *************** *** 638,641 **** --- 638,684 ---- call StopVimInTerminal(buf) endfunc + " this placed the cursor in the command line + func Test_smoothscroll_cursormoved_line() + CheckScreendump + + let lines =<< trim END + set smoothscroll + call setline(1, [ + \'', + \'_'->repeat(&lines * &columns), + \(('_')->repeat(&columns - 2) .. 'xxx')->repeat(2) + \]) + autocmd CursorMoved * eval [line('w0'), line('w$')] + call search('xxx') + END + call writefile(lines, 'XSmoothCursorMovedLine', 'D') + let buf = RunVimInTerminal('-S XSmoothCursorMovedLine', #{rows: 6}) + + call VerifyScreenDump(buf, 'Test_smooth_cursormoved_line', {}) + + call StopVimInTerminal(buf) + endfunc + + func Test_smoothscroll_eob() + CheckScreendump + + let lines =<< trim END + set smoothscroll + call setline(1, ['']->repeat(100)) + norm G + END + call writefile(lines, 'XSmoothEob', 'D') + let buf = RunVimInTerminal('-S XSmoothEob', #{rows: 10}) + + " does not scroll halfway when scrolling to end of buffer + call VerifyScreenDump(buf, 'Test_smooth_eob_1', {}) + + " cursor is not placed below window + call term_sendkeys(buf, ":call setline(92, 'a'->repeat(100))\\G") + call VerifyScreenDump(buf, 'Test_smooth_eob_2', {}) + + call StopVimInTerminal(buf) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1524/src/version.c 2023-05-08 15:31:34.251545087 +0100 --- src/version.c 2023-05-08 15:48:13.622576207 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1525, /**/ -- hundred-and-one symptoms of being an internet addict: 18. Your wife drapes a blond wig over your monitor to remind you of what she looks like. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///