comparison src/move.c @ 30745:fdc44acc3250 v9.0.0707

patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line Commit: https://github.com/vim/vim/commit/118c235112854f34182d968613d7fe98be3b290b Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 9 17:19:27 2022 +0100 patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line Problem: With 'smoothscroll' and 'scrolloff' non-zero the cursor position is not properly adjusted in a long line. Solution: Move the cursor further up or down in the line.
author Bram Moolenaar <Bram@vim.org>
date Sun, 09 Oct 2022 18:30:03 +0200
parents 5bea8e583d28
children ffa5492137c3
comparison
equal deleted inserted replaced
30744:74b682ee7339 30745:fdc44acc3250
1603 coladvance(curwin->w_curswant); 1603 coladvance(curwin->w_curswant);
1604 } 1604 }
1605 1605
1606 if (curwin->w_cursor.lnum == curwin->w_topline && do_sms) 1606 if (curwin->w_cursor.lnum == curwin->w_topline && do_sms)
1607 { 1607 {
1608 long so = curwin->w_p_so >= 0 ? curwin->w_p_so : p_so;
1609 int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
1610
1608 // make sure the cursor is in the visible text 1611 // make sure the cursor is in the visible text
1609 validate_virtcol(); 1612 validate_virtcol();
1610 int col = curwin->w_virtcol - curwin->w_skipcol; 1613 int col = curwin->w_virtcol - curwin->w_skipcol + scrolloff_cols;
1611 int row = 0; 1614 int row = 0;
1612 if (col >= width1) 1615 if (col >= width1)
1613 { 1616 {
1614 col -= width1; 1617 col -= width1;
1615 ++row; 1618 ++row;
1618 { 1621 {
1619 row += col / width2; 1622 row += col / width2;
1620 col = col % width2; 1623 col = col % width2;
1621 } 1624 }
1622 if (row >= curwin->w_height) 1625 if (row >= curwin->w_height)
1623 coladvance(curwin->w_virtcol 1626 {
1624 - (row - curwin->w_height + 1) * width2); 1627 curwin->w_curswant = curwin->w_virtcol
1628 - (row - curwin->w_height + 1) * width2;
1629 coladvance(curwin->w_curswant);
1630 }
1625 } 1631 }
1626 } 1632 }
1627 1633
1628 /* 1634 /*
1629 * Scroll the current window up by "line_count" logical lines. "CTRL-E" 1635 * Scroll the current window up by "line_count" logical lines. "CTRL-E"
1746 coladvance(curwin->w_curswant); 1752 coladvance(curwin->w_curswant);
1747 } 1753 }
1748 if (curwin->w_cursor.lnum == curwin->w_topline 1754 if (curwin->w_cursor.lnum == curwin->w_topline
1749 && do_sms && curwin->w_skipcol > 0) 1755 && do_sms && curwin->w_skipcol > 0)
1750 { 1756 {
1751 // make sure the cursor is in a visible part of the line 1757 int width1 = curwin->w_width - curwin_col_off();
1758 int width2 = width1 + curwin_col_off2();
1759 long so = curwin->w_p_so >= 0 ? curwin->w_p_so : p_so;
1760 int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
1761
1762 // Make sure the cursor is in a visible part of the line, taking
1763 // 'scrolloff' into account, but using screen lines.
1752 validate_virtcol(); 1764 validate_virtcol();
1753 if (curwin->w_virtcol < curwin->w_skipcol + 3) 1765 if (curwin->w_virtcol < curwin->w_skipcol + 3 + scrolloff_cols)
1754 { 1766 {
1755 int width1 = curwin->w_width - curwin_col_off();
1756 int width2 = width1 + curwin_col_off2();
1757 colnr_T col = curwin->w_virtcol; 1767 colnr_T col = curwin->w_virtcol;
1758 1768
1759 if (col < width1) 1769 if (col < width1)
1760 col += width1; 1770 col += width1;
1761 while (col < curwin->w_skipcol + 3) 1771 while (col < curwin->w_skipcol + 3 + scrolloff_cols)
1762 col += width2; 1772 col += width2;
1763 coladvance(col); 1773 curwin->w_curswant = col;
1774 coladvance(curwin->w_curswant);
1764 } 1775 }
1765 } 1776 }
1766 } 1777 }
1767 1778
1768 #ifdef FEAT_DIFF 1779 #ifdef FEAT_DIFF