mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Problem: Setting w_leftcol and handling side effects is confusing. Solution: Use a function to set w_leftcol() and handle side effects.
This commit is contained in:
28
src/normal.c
28
src/normal.c
@@ -1930,11 +1930,8 @@ check_scrollbind(linenr_T topline_diff, long leftcol_diff)
|
||||
}
|
||||
|
||||
// do the horizontal scroll
|
||||
if (want_hor && curwin->w_leftcol != tgt_leftcol)
|
||||
{
|
||||
curwin->w_leftcol = tgt_leftcol;
|
||||
leftcol_changed();
|
||||
}
|
||||
if (want_hor)
|
||||
(void)set_leftcol(tgt_leftcol);
|
||||
}
|
||||
|
||||
// reset current-window
|
||||
@@ -2458,7 +2455,7 @@ scroll_redraw(int up, long count)
|
||||
scrollup(count, TRUE);
|
||||
else
|
||||
scrolldown(count, TRUE);
|
||||
if (get_scrolloff_value())
|
||||
if (get_scrolloff_value() > 0)
|
||||
{
|
||||
// Adjust the cursor position for 'scrolloff'. Mark w_topline as
|
||||
// valid, otherwise the screen jumps back at the end of the file.
|
||||
@@ -2734,28 +2731,19 @@ nv_zet(cmdarg_T *cap)
|
||||
case 'h':
|
||||
case K_LEFT:
|
||||
if (!curwin->w_p_wrap)
|
||||
{
|
||||
if ((colnr_T)cap->count1 > curwin->w_leftcol)
|
||||
curwin->w_leftcol = 0;
|
||||
else
|
||||
curwin->w_leftcol -= (colnr_T)cap->count1;
|
||||
leftcol_changed();
|
||||
}
|
||||
(void)set_leftcol((colnr_T)cap->count1 > curwin->w_leftcol
|
||||
? 0 : curwin->w_leftcol - (colnr_T)cap->count1);
|
||||
break;
|
||||
|
||||
// "zL" - scroll screen left half-page
|
||||
// "zL" - scroll window left half-page
|
||||
case 'L': cap->count1 *= curwin->w_width / 2;
|
||||
// FALLTHROUGH
|
||||
|
||||
// "zl" - scroll screen to the left
|
||||
// "zl" - scroll window to the left if not wrapping
|
||||
case 'l':
|
||||
case K_RIGHT:
|
||||
if (!curwin->w_p_wrap)
|
||||
{
|
||||
// scroll the window left
|
||||
curwin->w_leftcol += (colnr_T)cap->count1;
|
||||
leftcol_changed();
|
||||
}
|
||||
(void)set_leftcol(curwin->w_leftcol + (colnr_T)cap->count1);
|
||||
break;
|
||||
|
||||
// "zs" - scroll screen, cursor at the start
|
||||
|
Reference in New Issue
Block a user