To: vim_dev@googlegroups.com Subject: Patch 9.0.1512 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1512 Problem: Inserting lines when scrolling with 'smoothscroll' set. Solution: Adjust line height computation for w_skipcol. (Luuk van Baal, closes #12350) Files: src/drawscreen.c, src/move.c, src/proto/move.pro, src/testdir/test_scroll_opt.vim, src/testdir/dumps/Test_smooth_ins_lines.dump *** ../vim-9.0.1511/src/drawscreen.c 2022-12-15 13:14:17.411527402 +0000 --- src/drawscreen.c 2023-05-06 12:32:43.123400784 +0100 *************** *** 2327,2334 **** { #ifdef FEAT_DIFF if (l == wp->w_topline) ! new_rows += plines_win_nofill(wp, l, TRUE) ! + wp->w_topfill; else #endif new_rows += plines_win(wp, l, TRUE); --- 2327,2340 ---- { #ifdef FEAT_DIFF if (l == wp->w_topline) ! { ! int n = plines_win_nofill(wp, l, FALSE) ! + wp->w_topfill; ! n = adjust_plines_for_skipcol(wp, n); ! if (n > wp->w_height) ! n = wp->w_height; ! new_rows += n; ! } else #endif new_rows += plines_win(wp, l, TRUE); *** ../vim-9.0.1511/src/move.c 2023-04-01 19:54:36.452530922 +0100 --- src/move.c 2023-05-06 12:32:43.123400784 +0100 *************** *** 38,44 **** /* * Reduce "n" for the screen lines skipped with "wp->w_skipcol". */ ! static int adjust_plines_for_skipcol(win_T *wp, int n) { if (wp->w_skipcol == 0) --- 38,44 ---- /* * Reduce "n" for the screen lines skipped with "wp->w_skipcol". */ ! int adjust_plines_for_skipcol(win_T *wp, int n) { if (wp->w_skipcol == 0) *************** *** 239,245 **** } /* ! * Set curwin->s_skipcol to zero and redraw later if needed. */ static void reset_skipcol(void) --- 239,245 ---- } /* ! * Set curwin->w_skipcol to zero and redraw later if needed. */ static void reset_skipcol(void) *************** *** 2990,2996 **** if (curwin->w_p_sms && !curwin->w_p_wrap) { ! // 'smoothscroll is active if (curwin->w_cline_height == curwin->w_height) { // The cursor line just fits in the window, don't scroll. --- 2990,2996 ---- if (curwin->w_p_sms && !curwin->w_p_wrap) { ! // 'smoothscroll' is active if (curwin->w_cline_height == curwin->w_height) { // The cursor line just fits in the window, don't scroll. *** ../vim-9.0.1511/src/proto/move.pro 2023-02-14 17:41:15.774305998 +0000 --- src/proto/move.pro 2023-05-06 12:35:10.678353214 +0100 *************** *** 1,4 **** --- 1,5 ---- /* move.c */ + int adjust_plines_for_skipcol(win_T *wp, int n); void redraw_for_cursorline(win_T *wp); void update_topline_redraw(void); void update_topline(void); *** ../vim-9.0.1511/src/testdir/test_scroll_opt.vim 2023-05-02 20:52:32.047787527 +0100 --- src/testdir/test_scroll_opt.vim 2023-05-06 12:37:07.481704727 +0100 *************** *** 587,593 **** endfunc " this was dividing by zero ! func Test_smoothscrol_zero_width() CheckScreendump let lines =<< trim END --- 587,593 ---- endfunc " this was dividing by zero ! func Test_smoothscroll_zero_width() CheckScreendump let lines =<< trim END *************** *** 613,617 **** --- 613,642 ---- call StopVimInTerminal(buf) endfunc + " this was unnecessarily inserting lines + func Test_smoothscroll_ins_lines() + CheckScreendump + + let lines =<< trim END + set wrap + set smoothscroll + set scrolloff=0 + set conceallevel=2 + call setline(1, [ + \'line one' .. 'with lots of text in one line '->repeat(2), + \'line two', + \'line three', + \'line four', + \'line five' + \]) + END + call writefile(lines, 'XSmoothScrollInsLines', 'D') + let buf = RunVimInTerminal('-S XSmoothScrollInsLines', #{rows: 6, cols: 40}) + + call term_sendkeys(buf, "\gjgk") + call VerifyScreenDump(buf, 'Test_smooth_ins_lines', {}) + + call StopVimInTerminal(buf) + endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1511/src/testdir/dumps/Test_smooth_ins_lines.dump 2023-05-06 12:39:24.333101249 +0100 --- src/testdir/dumps/Test_smooth_ins_lines.dump 2023-05-06 12:32:43.127400754 +0100 *************** *** 0 **** --- 1,6 ---- + |<+0#4040ff13#ffffff0@2|l+0#0000000&|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e> @12 + |l|i|n|e| |t|w|o| @31 + |l|i|n|e| |t|h|r|e@1| @29 + |l|i|n|e| |f|o|u|r| @30 + |l|i|n|e| |f|i|v|e| @30 + @22|1|,|6|8| @9|A|l@1| *** ../vim-9.0.1511/src/version.c 2023-05-06 12:20:01.824191203 +0100 --- src/version.c 2023-05-06 12:39:08.681162963 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1512, /**/ -- Never enter the boss's office unless it's absolutely necessary. Every boss saves one corner of the desk for useless assignments that are doled out like Halloween candy to each visitor. (Scott Adams - The Dilbert principle) /// 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 ///