fix(api/buffer): fix handling of viewport of non-current buffer

A lot of functions in move.c only worked for curwin, alternatively
took a `wp` arg but still only work if that happens to be curwin.

Refactor those that are needed for update_topline(wp) to work
for any window.

fixes #27723
fixes #27720
This commit is contained in:
bfredl
2024-03-11 13:19:49 +01:00
parent d5488633f6
commit 08fc1ebbaa
50 changed files with 844 additions and 814 deletions

View File

@@ -187,7 +187,7 @@ bool findpar(bool *pincl, int dir, int count, int what, bool both)
// skip folded lines
fold_skipped = false;
if (first && hasFolding(curr, &fold_first, &fold_last)) {
if (first && hasFolding(curwin, curr, &fold_first, &fold_last)) {
curr = ((dir > 0) ? fold_last : fold_first) + dir;
fold_skipped = true;
}
@@ -318,8 +318,8 @@ int fwd_word(int count, bool bigword, bool eol)
while (--count >= 0) {
// When inside a range of folded lines, move to the last char of the
// last line.
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
coladvance(MAXCOL);
if (hasFolding(curwin, curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
coladvance(curwin, MAXCOL);
}
int sclass = cls(); // starting class
@@ -374,7 +374,7 @@ int bck_word(int count, bool bigword, bool stop)
while (--count >= 0) {
// When inside a range of folded lines, move to the first char of the
// first line.
if (hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL)) {
if (hasFolding(curwin, curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL)) {
curwin->w_cursor.col = 0;
}
sclass = cls();
@@ -431,8 +431,8 @@ int end_word(int count, bool bigword, bool stop, bool empty)
while (--count >= 0) {
// When inside a range of folded lines, move to the last char of the
// last line.
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
coladvance(MAXCOL);
if (hasFolding(curwin, curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
coladvance(curwin, MAXCOL);
}
sclass = cls();
if (inc_cursor() == -1) {