mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
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:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user