diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-08-26 12:35:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-26 12:35:22 +0200 |
commit | 1bdcb9aaf11e914d4c7af14e8e5be4ed3c5798ae (patch) | |
tree | b86dfc90f7208a5225e2479b8fceda38d44001e3 /src/nvim/cursor.c | |
parent | 5bb17958c5694a28bd6b97f97adb4064bc79b984 (diff) | |
parent | 008154954791001efcc46c28146e21403f3a698b (diff) | |
download | rneovim-1bdcb9aaf11e914d4c7af14e8e5be4ed3c5798ae.tar.gz rneovim-1bdcb9aaf11e914d4c7af14e8e5be4ed3c5798ae.tar.bz2 rneovim-1bdcb9aaf11e914d4c7af14e8e5be4ed3c5798ae.zip |
Merge pull request #24824 from bfredl/nocurbuf
refactor(change): do API changes to buffer without curbuf switch
Diffstat (limited to 'src/nvim/cursor.c')
-rw-r--r-- | src/nvim/cursor.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index f7a456f4c7..2dc903309e 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -324,18 +324,18 @@ void check_pos(buf_T *buf, pos_T *pos) } /// Make sure curwin->w_cursor.lnum is valid. -void check_cursor_lnum(void) +void check_cursor_lnum(win_T *win) { - if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { + buf_T *buf = win->w_buffer; + if (win->w_cursor.lnum > buf->b_ml.ml_line_count) { // If there is a closed fold at the end of the file, put the cursor in // its first line. Otherwise in the last line. - if (!hasFolding(curbuf->b_ml.ml_line_count, - &curwin->w_cursor.lnum, NULL)) { - curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; + if (!hasFolding(buf->b_ml.ml_line_count, &win->w_cursor.lnum, NULL)) { + win->w_cursor.lnum = buf->b_ml.ml_line_count; } } - if (curwin->w_cursor.lnum <= 0) { - curwin->w_cursor.lnum = 1; + if (win->w_cursor.lnum <= 0) { + win->w_cursor.lnum = 1; } } @@ -406,7 +406,7 @@ void check_cursor_col_win(win_T *win) /// Make sure curwin->w_cursor in on a valid character void check_cursor(void) { - check_cursor_lnum(); + check_cursor_lnum(curwin); check_cursor_col(); } @@ -451,7 +451,7 @@ bool set_leftcol(colnr_T leftcol) } curwin->w_leftcol = leftcol; - changed_cline_bef_curs(); + changed_cline_bef_curs(curwin); // TODO(hinidu): I think it should be colnr_T or int, but p_siso is long. // Perhaps we can change p_siso to int. int64_t lastcol = curwin->w_leftcol + curwin->w_width_inner - curwin_col_off() - 1; @@ -481,7 +481,7 @@ bool set_leftcol(colnr_T leftcol) retval = true; if (coladvance(e + 1) == FAIL) { // there isn't another character curwin->w_leftcol = s; // adjust w_leftcol instead - changed_cline_bef_curs(); + changed_cline_bef_curs(curwin); } } |