Respect scroll offset even when wrapping lines
Fixes #1433 although in a slightly different way than requested: We ensure that scrolloff *displayed* lines are visible below the cursor, not scrolloff *buffer* lines.
This commit is contained in:
parent
e73cd78288
commit
40f845d77e
|
@ -788,7 +788,8 @@ struct WrapHighlighter : Highlighter
|
||||||
win_line += wrap_count + 1;
|
win_line += wrap_count + 1;
|
||||||
|
|
||||||
// scroll window to keep cursor visible, and update range as lines gets removed
|
// scroll window to keep cursor visible, and update range as lines gets removed
|
||||||
while (setup.window_pos.line < cursor.line and setup.cursor_pos.line >= win_height)
|
while (setup.window_pos.line < cursor.line and
|
||||||
|
setup.cursor_pos.line >= win_height - setup.scroll_offset.line)
|
||||||
{
|
{
|
||||||
auto removed_lines = 1 + line_wrap_count(setup.window_pos.line++);
|
auto removed_lines = 1 + line_wrap_count(setup.window_pos.line++);
|
||||||
setup.cursor_pos.line -= removed_lines;
|
setup.cursor_pos.line -= removed_lines;
|
||||||
|
|
1
test/regression/1433-scrolloff-broken-with-soft-wrap/cmd
Normal file
1
test/regression/1433-scrolloff-broken-with-soft-wrap/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
22jgl
|
|
@ -0,0 +1,6 @@
|
||||||
|
{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "2\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "3\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "4\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "5\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "6\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "7\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "8\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "9\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "10\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "11\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "12\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "13\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "14\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "15\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "16\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "17\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "18\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "19\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "20\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "21\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "22\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "23 -----------------------------------------------------------------------------" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "wra" }, { "face": { "fg": "black", "bg": "white", "attributes": [] }, "contents": "p" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "24\u000a" }]], { "fg": "default", "bg": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "attributes": [] }] }
|
||||||
|
{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] }
|
||||||
|
{ "jsonrpc": "2.0", "method": "info_hide", "params": [] }
|
||||||
|
{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "out 23:84 " }, { "face": { "fg": "black", "bg": "yellow", "attributes": [] }, "contents": "" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " - unnamed0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "attributes": [] }] }
|
||||||
|
{ "jsonrpc": "2.0", "method": "set_cursor", "params": ["buffer", { "line": 22, "column": 3 }] }
|
||||||
|
{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }
|
26
test/regression/1433-scrolloff-broken-with-soft-wrap/in
Normal file
26
test/regression/1433-scrolloff-broken-with-soft-wrap/in
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
20
|
||||||
|
21
|
||||||
|
22
|
||||||
|
23 -----------------------------------------------------------------------------wrap
|
||||||
|
24
|
||||||
|
25
|
||||||
|
26
|
2
test/regression/1433-scrolloff-broken-with-soft-wrap/rc
Normal file
2
test/regression/1433-scrolloff-broken-with-soft-wrap/rc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
add-highlighter wrap
|
||||||
|
set global scrolloff 1,0
|
Loading…
Reference in New Issue
Block a user