diff --git a/src/highlighters.cc b/src/highlighters.cc index 7b268bcb..22047097 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -719,7 +719,7 @@ struct WrapHighlighter : Highlighter const ColumnCount marker_len = zero_if_greater(m_marker.column_length(), wrap_column); for (auto buf_line = setup.first_line, win_line = 0_line; - win_line < win_height or buf_line <= cursor.line; + win_line < win_height or (setup.ensure_cursor_visible and buf_line <= cursor.line); ++buf_line, ++setup.line_count) { if (buf_line >= buffer.line_count()) diff --git a/src/window.cc b/src/window.cc index 1f444211..e296a62d 100644 --- a/src/window.cc +++ b/src/window.cc @@ -148,6 +148,8 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context) for (auto& line : m_display_buffer.lines()) line.trim_from(setup.widget_columns, setup.first_column, m_dimensions.column); + if (m_display_buffer.lines().size() > m_dimensions.line) + m_display_buffer.lines().resize((size_t)m_dimensions.line); m_builtin_highlighters.highlight({context, setup, HighlightPass::Colorize, {}}, m_display_buffer, range); diff --git a/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/cmd b/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/cmd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/cmd @@ -0,0 +1 @@ + diff --git a/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/in b/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/in new file mode 100644 index 00000000..898d6e83 --- /dev/null +++ b/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/in @@ -0,0 +1,29 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +%(29) diff --git a/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/rc b/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/rc new file mode 100644 index 00000000..2cd258c4 --- /dev/null +++ b/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/rc @@ -0,0 +1 @@ +add-highlighter window/ wrap diff --git a/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/script b/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/script new file mode 100644 index 00000000..ef4a1d65 --- /dev/null +++ b/test/regression/5118-crash-on-scroll-with-insert-completion-and-wrap/script @@ -0,0 +1,6 @@ +ui_out -ignore 6 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "a2" ] }' +ui_out -until-grep menu_show >/dev/null +ui_out -ignore 5 +ui_in '{ "jsonrpc": "2.0", "method": "scroll", "params": [ -5 ] }' +ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "2\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "3\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "4\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "5\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "6\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "7\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "8\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "9\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "10\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "11\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "12\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "13\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "14\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "15\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "16\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "17\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "18\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "19\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "20\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "21\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "22\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "23\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "24\u000a" }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'