To: vim_dev@googlegroups.com Subject: Patch 9.0.0701 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0701 Problem: With 'smoothscroll' the cursor position s not adjusted in a long line. Solution: Move the cursor further up or down in the line. Files: src/move.c, src/testdir/test_scroll_opt.vim, src/testdir/dumps/Test_smooth_long_1.dump, src/testdir/dumps/Test_smooth_long_2.dump, src/testdir/dumps/Test_smooth_long_3.dump, src/testdir/dumps/Test_smooth_long_4.dump, src/testdir/dumps/Test_smooth_long_5.dump *** ../vim-9.0.0700/src/move.c 2022-10-06 16:03:02.597971612 +0100 --- src/move.c 2022-10-08 21:12:00.860966716 +0100 *************** *** 1602,1607 **** --- 1602,1628 ---- #endif coladvance(curwin->w_curswant); } + + if (curwin->w_cursor.lnum == curwin->w_topline && do_sms) + { + // make sure the cursor is in the visible text + validate_virtcol(); + int col = curwin->w_virtcol - curwin->w_skipcol; + int row = 0; + if (col >= width1) + { + col -= width1; + ++row; + } + if (col > width2) + { + row += col / width2; + col = col % width2; + } + if (row >= curwin->w_height) + coladvance(curwin->w_virtcol + - (row - curwin->w_height + 1) * width2); + } } /* *************** *** 1651,1658 **** // for a closed fold: go to the last line in the fold (void)hasFolding(lnum, NULL, &lnum); # endif ! if (lnum == curwin->w_topline ! && curwin->w_p_wrap && curwin->w_p_sms) { // 'smoothscroll': increase "w_skipcol" until it goes over // the end of the line, then advance to the next line. --- 1672,1678 ---- // for a closed fold: go to the last line in the fold (void)hasFolding(lnum, NULL, &lnum); # endif ! if (lnum == curwin->w_topline && do_sms) { // 'smoothscroll': increase "w_skipcol" until it goes over // the end of the line, then advance to the next line. *************** *** 1725,1730 **** --- 1745,1768 ---- ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW|VALID_VIRTCOL); coladvance(curwin->w_curswant); } + if (curwin->w_cursor.lnum == curwin->w_topline + && do_sms && curwin->w_skipcol > 0) + { + // make sure the cursor is in a visible part of the line + validate_virtcol(); + if (curwin->w_virtcol < curwin->w_skipcol + 3) + { + int width1 = curwin->w_width - curwin_col_off(); + int width2 = width1 + curwin_col_off2(); + colnr_T col = curwin->w_virtcol; + + if (col < width1) + col += width1; + while (col < curwin->w_skipcol + 3) + col += width2; + coladvance(col); + } + } } #ifdef FEAT_DIFF *** ../vim-9.0.0700/src/testdir/test_scroll_opt.vim 2022-10-06 15:46:27.932240365 +0100 --- src/testdir/test_scroll_opt.vim 2022-10-08 21:04:54.537710145 +0100 *************** *** 198,202 **** --- 198,230 ---- call StopVimInTerminal(buf) endfunc + func Test_smoothscroll_wrap_long_line() + CheckScreendump + + let lines =<< trim END + vim9script + setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(30))]) + set smoothscroll scrolloff=0 + normal 3G10|zt + END + call writefile(lines, 'XSmoothWrap', 'D') + let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 6, cols: 40}) + call VerifyScreenDump(buf, 'Test_smooth_long_1', {}) + + " scrolling up, cursor moves screen line down + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_smooth_long_2', {}) + call term_sendkeys(buf, "5\") + call VerifyScreenDump(buf, 'Test_smooth_long_3', {}) + + " scrolling down, cursor moves screen line up + call term_sendkeys(buf, "5\") + call VerifyScreenDump(buf, 'Test_smooth_long_4', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_smooth_long_5', {}) + + call StopVimInTerminal(buf) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.0700/src/testdir/dumps/Test_smooth_long_1.dump 2022-10-08 21:12:28.088925873 +0100 --- src/testdir/dumps/Test_smooth_long_1.dump 2022-10-08 21:06:46.409375942 +0100 *************** *** 0 **** --- 1,6 ---- + |L+0&#ffffff0|i|n|e| |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| |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 + | @21|3|,|1|0| @9|B|o|t| *** ../vim-9.0.0700/src/testdir/dumps/Test_smooth_long_2.dump 2022-10-08 21:12:28.096925863 +0100 --- src/testdir/dumps/Test_smooth_long_2.dump 2022-10-08 21:06:47.557372517 +0100 *************** *** 0 **** --- 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| |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 + | @21|3|,|5|0| @9|B|o|t| *** ../vim-9.0.0700/src/testdir/dumps/Test_smooth_long_3.dump 2022-10-08 21:12:28.100925856 +0100 --- src/testdir/dumps/Test_smooth_long_3.dump 2022-10-08 21:06:48.709369078 +0100 *************** *** 0 **** --- 1,6 ---- + |<+0#4040ff13#ffffff0@2| +0#0000000&|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| |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 + | @21|3|,|2|5|0| @8|B|o|t| *** ../vim-9.0.0700/src/testdir/dumps/Test_smooth_long_4.dump 2022-10-08 21:12:28.104925851 +0100 --- src/testdir/dumps/Test_smooth_long_4.dump 2022-10-08 21:06:49.857365652 +0100 *************** *** 0 **** --- 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| |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 + | @21|3|,|2|1|0| @8|B|o|t| *** ../vim-9.0.0700/src/testdir/dumps/Test_smooth_long_5.dump 2022-10-08 21:12:28.108925843 +0100 --- src/testdir/dumps/Test_smooth_long_5.dump 2022-10-08 21:06:51.009362213 +0100 *************** *** 0 **** --- 1,6 ---- + |L+0&#ffffff0|i|n|e| |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| |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 + | @21|3|,|1|7|0| @8|B|o|t| *** ../vim-9.0.0700/src/version.c 2022-10-08 19:26:35.702195359 +0100 --- src/version.c 2022-10-08 21:06:32.273418165 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 701, /**/ -- FATHER: Who are you? PRINCE: I'm ... your son ... FATHER: Not you. LAUNCELOT: I'm ... er ... Sir Launcelot, sir. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///