To: vim_dev@googlegroups.com Subject: Patch 9.0.0671 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0671 Problem: Negative topline using CTRL-Y with 'smoothscroll' and 'diff'. (Ernie Rael) Solution: Only use 'smoothscroll' when 'wrap' is set. Files: src/move.c, src/testdir/test_scroll_opt.vim, src/testdir/dumps/Test_smooth_diff_1.dump *** ../vim-9.0.0670/src/move.c 2022-10-04 16:23:39.018042176 +0100 --- src/move.c 2022-10-06 13:07:33.987265191 +0100 *************** *** 1458,1467 **** long done = 0; // total # of physical lines done int wrow; int moved = FALSE; int width1 = 0; int width2 = 0; ! if (curwin->w_p_wrap && curwin->w_p_sms) { width1 = curwin->w_width - curwin_col_off(); width2 = width1 + curwin_col_off2(); --- 1458,1468 ---- long done = 0; // total # of physical lines done int wrow; int moved = FALSE; + int do_sms = curwin->w_p_wrap && curwin->w_p_sms; int width1 = 0; int width2 = 0; ! if (do_sms) { width1 = curwin->w_width - curwin_col_off(); width2 = width1 + curwin_col_off2(); *************** *** 1474,1480 **** (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); #endif validate_cursor(); // w_wrow needs to be valid ! while (line_count-- > 0) { #ifdef FEAT_DIFF if (curwin->w_topfill < diff_check(curwin, curwin->w_topline) --- 1475,1481 ---- (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); #endif validate_cursor(); // w_wrow needs to be valid ! for (int todo = line_count; todo > 0; --todo) { #ifdef FEAT_DIFF if (curwin->w_topfill < diff_check(curwin, curwin->w_topline) *************** *** 1488,1497 **** { // break when at the very top if (curwin->w_topline == 1 ! && (!curwin->w_p_sms || curwin->w_skipcol < width1)) break; ! if (curwin->w_p_wrap && curwin->w_p_sms ! && curwin->w_skipcol >= width1) { // scroll a screen line down if (curwin->w_skipcol >= width1 + width2) --- 1489,1497 ---- { // break when at the very top if (curwin->w_topline == 1 ! && (!do_sms || curwin->w_skipcol < width1)) break; ! if (do_sms && curwin->w_skipcol >= width1) { // scroll a screen line down if (curwin->w_skipcol >= width1 + width2) *************** *** 1515,1527 **** { ++done; if (!byfold) ! line_count -= curwin->w_topline - first - 1; curwin->w_botline -= curwin->w_topline - first; curwin->w_topline = first; } else #endif ! if (curwin->w_p_wrap && curwin->w_p_sms) { int size = win_linetabsize(curwin, curwin->w_topline, ml_get(curwin->w_topline), (colnr_T)MAXCOL); --- 1515,1527 ---- { ++done; if (!byfold) ! todo -= curwin->w_topline - first - 1; curwin->w_botline -= curwin->w_topline - first; curwin->w_topline = first; } else #endif ! if (do_sms) { int size = win_linetabsize(curwin, curwin->w_topline, ml_get(curwin->w_topline), (colnr_T)MAXCOL); *************** *** 1602,1610 **** long line_count, int byfold UNUSED) // TRUE: count a closed fold as one line { ! int do_smoothscroll = curwin->w_p_wrap && curwin->w_p_sms; ! if (do_smoothscroll # ifdef FEAT_FOLDING || (byfold && hasAnyFolding(curwin)) # endif --- 1602,1610 ---- long line_count, int byfold UNUSED) // TRUE: count a closed fold as one line { ! int do_sms = curwin->w_p_wrap && curwin->w_p_sms; ! if (do_sms # ifdef FEAT_FOLDING || (byfold && hasAnyFolding(curwin)) # endif *************** *** 1618,1624 **** int size = 0; linenr_T prev_topline = curwin->w_topline; ! if (do_smoothscroll) size = win_linetabsize(curwin, curwin->w_topline, ml_get(curwin->w_topline), (colnr_T)MAXCOL); --- 1618,1624 ---- int size = 0; linenr_T prev_topline = curwin->w_topline; ! if (do_sms) size = win_linetabsize(curwin, curwin->w_topline, ml_get(curwin->w_topline), (colnr_T)MAXCOL); *************** *** 1675,1681 **** curwin->w_topfill = diff_check_fill(curwin, lnum); # endif curwin->w_skipcol = 0; ! if (todo > 1 && do_smoothscroll) size = win_linetabsize(curwin, curwin->w_topline, ml_get(curwin->w_topline), (colnr_T)MAXCOL); } --- 1675,1681 ---- curwin->w_topfill = diff_check_fill(curwin, lnum); # endif curwin->w_skipcol = 0; ! if (todo > 1 && do_sms) size = win_linetabsize(curwin, curwin->w_topline, ml_get(curwin->w_topline), (colnr_T)MAXCOL); } *** ../vim-9.0.0670/src/testdir/test_scroll_opt.vim 2022-10-03 20:00:49.396319098 +0100 --- src/testdir/test_scroll_opt.vim 2022-10-06 13:06:00.587586789 +0100 *************** *** 141,146 **** --- 141,172 ---- call StopVimInTerminal(buf) endfunc + func Test_smoothscroll_diff_mode() + CheckScreendump + + let lines =<< trim END + vim9script + var text = 'just some text here' + setline(1, text) + set smoothscroll + diffthis + new + setline(1, text) + set smoothscroll + diffthis + END + call writefile(lines, 'XSmoothDiff', 'D') + let buf = RunVimInTerminal('-S XSmoothDiff', #{rows: 8}) + + call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) + + call StopVimInTerminal(buf) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.0670/src/testdir/dumps/Test_smooth_diff_1.dump 2022-10-06 13:07:58.891179509 +0100 --- src/testdir/dumps/Test_smooth_diff_1.dump 2022-10-06 13:06:06.051567960 +0100 *************** *** 0 **** --- 1,8 ---- + |-+0#0000e05#a8a8a8255| >j+0#0000000#ffffff0|u|s|t| |s|o|m|e| |t|e|x|t| |h|e|r|e| @53 + |~+0#4040ff13&| @73 + |~| @73 + |[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|A|l@1 + |-+0#0000e05#a8a8a8255| |j+0#0000000#ffffff0|u|s|t| |s|o|m|e| |t|e|x|t| |h|e|r|e| @53 + |~+0#4040ff13&| @73 + |[+1#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|A|l@1 + | +0&&@74 *** ../vim-9.0.0670/src/version.c 2022-10-06 11:38:48.154906022 +0100 --- src/version.c 2022-10-06 13:00:06.640811094 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 671, /**/ -- Facepalm statement #9: "Did you see, there is now even a hobbit book" /// 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 ///