mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.0357: Page scrolling should place cursor at window boundaries (#28429)
Problem: Page scrolling does not always place the cursor at the top or
bottom of the window (Mathias Rav)
Solution: Place the cursor at the top or bottom of the window.
(Luuk van Baal)
4b6b0c4024
This commit is contained in:
parent
783b0aba41
commit
ea1c9f60e0
@ -2492,23 +2492,27 @@ int pagescroll(Direction dir, int count, bool half)
|
|||||||
} else {
|
} else {
|
||||||
cursor_up_inner(curwin, curscount);
|
cursor_up_inner(curwin, curscount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_scrolloff_value(curwin) > 0) {
|
|
||||||
cursor_correct(curwin);
|
|
||||||
}
|
|
||||||
// Move cursor to first line of closed fold.
|
|
||||||
foldAdjustCursor(curwin);
|
|
||||||
|
|
||||||
nochange = nochange
|
|
||||||
&& prev_col == curwin->w_cursor.col
|
|
||||||
&& prev_lnum == curwin->w_cursor.lnum;
|
|
||||||
} else {
|
} else {
|
||||||
// Scroll [count] times 'window' or current window height lines.
|
// Scroll [count] times 'window' or current window height lines.
|
||||||
count *= ((ONE_WINDOW && p_window > 0 && p_window < Rows - 1)
|
count *= ((ONE_WINDOW && p_window > 0 && p_window < Rows - 1)
|
||||||
? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir));
|
? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir));
|
||||||
nochange = scroll_with_sms(dir, count);
|
nochange = scroll_with_sms(dir, count);
|
||||||
|
|
||||||
|
// Place cursor at top or bottom of window.
|
||||||
|
validate_botline(curwin);
|
||||||
|
curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline : curwin->w_botline - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get_scrolloff_value(curwin) > 0) {
|
||||||
|
cursor_correct(curwin);
|
||||||
|
}
|
||||||
|
// Move cursor to first line of closed fold.
|
||||||
|
foldAdjustCursor(curwin);
|
||||||
|
|
||||||
|
nochange = nochange
|
||||||
|
&& prev_col == curwin->w_cursor.col
|
||||||
|
&& prev_lnum == curwin->w_cursor.lnum;
|
||||||
|
|
||||||
// Error if both the viewport and cursor did not change.
|
// Error if both the viewport and cursor did not change.
|
||||||
if (nochange) {
|
if (nochange) {
|
||||||
beep_flush();
|
beep_flush();
|
||||||
|
@ -4268,7 +4268,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
|||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
{16:refactor(khash): }take size of values as parameter |
|
{16:refactor(khash): }take size of values as parameter |
|
||||||
Author: Dev Devsson, {18:Tue Aug 31 10:13:37 2021} |
|
Author: Dev Devsson, {18:Tue Aug 31 10:13:37 2021} |
|
||||||
^if (h->n_buckets < new_n_buckets) { // expand |
|
if (h->n_buckets < new_n_buckets) { // expand |
|
||||||
khkey_t *new_keys = (khkey_t *)krealloc((void *)|
|
khkey_t *new_keys = (khkey_t *)krealloc((void *)|
|
||||||
h->keys, new_n_buckets * sizeof(khkey_t)); |
|
h->keys, new_n_buckets * sizeof(khkey_t)); |
|
||||||
h->keys = new_keys; |
|
h->keys = new_keys; |
|
||||||
@ -4276,7 +4276,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
|||||||
char *new_vals = krealloc( h->vals_buf, new_n_|
|
char *new_vals = krealloc( h->vals_buf, new_n_|
|
||||||
buckets * val_size); |
|
buckets * val_size); |
|
||||||
h->vals_buf = new_vals; |
|
h->vals_buf = new_vals; |
|
||||||
} |
|
^} |
|
||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
@ -4949,8 +4949,8 @@ if (h->n_buckets < new_n_buckets) { // expand
|
|||||||
VIRT2 |
|
VIRT2 |
|
||||||
11 |
|
11 |
|
||||||
12 |
|
12 |
|
||||||
^13 |
|
13 |
|
||||||
14 |
|
^14 |
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
feed('<C-B>')
|
feed('<C-B>')
|
||||||
|
@ -3823,8 +3823,8 @@ func Test_normal_vert_scroll_longline()
|
|||||||
call assert_equal(11, line('.'))
|
call assert_equal(11, line('.'))
|
||||||
call assert_equal(1, winline())
|
call assert_equal(1, winline())
|
||||||
exe "normal \<C-B>"
|
exe "normal \<C-B>"
|
||||||
call assert_equal(10, line('.'))
|
call assert_equal(11, line('.'))
|
||||||
call assert_equal(4, winline())
|
call assert_equal(5, winline())
|
||||||
exe "normal \<C-B>\<C-B>"
|
exe "normal \<C-B>\<C-B>"
|
||||||
call assert_equal(5, line('.'))
|
call assert_equal(5, line('.'))
|
||||||
call assert_equal(5, winline())
|
call assert_equal(5, winline())
|
||||||
@ -4257,4 +4257,17 @@ func Test_halfpage_cursor_startend()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for Ctrl-F/B moving the cursor to the window boundaries.
|
||||||
|
func Test_page_cursor_topbot()
|
||||||
|
10new
|
||||||
|
call setline(1, range(1, 100))
|
||||||
|
exe "norm! gg2\<C-F>"
|
||||||
|
call assert_equal(17, line('.'))
|
||||||
|
exe "norm! \<C-B>"
|
||||||
|
call assert_equal(18, line('.'))
|
||||||
|
exe "norm! \<C-B>\<C-F>"
|
||||||
|
call assert_equal(9, line('.'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
|
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
|
||||||
|
Loading…
Reference in New Issue
Block a user