Fix assert with window small enough so that no part of buffer is displayed

Fixes #2056
This commit is contained in:
Maxime Coste 2018-05-19 10:46:23 +10:00
parent a64afd7f1a
commit c9a8658671
6 changed files with 25 additions and 2 deletions

View File

@ -1064,7 +1064,7 @@ private:
return; return;
ColumnCount width = compute_digit_count(context.context) + m_separator.column_length(); ColumnCount width = compute_digit_count(context.context) + m_separator.column_length();
setup.window_range.column -= width; setup.window_range.column -= std::min(width, setup.window_range.column);
} }
void fill_unique_ids(Vector<StringView>& unique_ids) const override void fill_unique_ids(Vector<StringView>& unique_ids) const override
@ -1347,7 +1347,7 @@ private:
return; return;
} }
setup.window_range.column -= width; setup.window_range.column -= std::min(width, setup.window_range.column);
} }
String m_option_name; String m_option_name;

View File

@ -190,6 +190,14 @@ void Window::set_dimensions(DisplayCoord dimensions)
} }
} }
static void check_display_setup(const DisplaySetup& setup, const Window& window)
{
kak_assert(setup.window_pos.line >= 0 and setup.window_pos.line < window.buffer().line_count());
kak_assert(setup.window_pos.column >= 0);
kak_assert(setup.window_range.column >= 0);
kak_assert(setup.window_range.line >= 0);
}
DisplaySetup Window::compute_display_setup(const Context& context) const DisplaySetup Window::compute_display_setup(const Context& context) const
{ {
auto win_pos = m_position; auto win_pos = m_position;
@ -217,6 +225,7 @@ DisplaySetup Window::compute_display_setup(const Context& context) const
}; };
for (auto pass : { HighlightPass::Move, HighlightPass::Wrap }) for (auto pass : { HighlightPass::Move, HighlightPass::Wrap })
m_builtin_highlighters.compute_display_setup({context, pass, {}}, setup); m_builtin_highlighters.compute_display_setup({context, pass, {}}, setup);
check_display_setup(setup, *this);
// now ensure the cursor column is visible // now ensure the cursor column is visible
{ {
@ -233,6 +242,7 @@ DisplaySetup Window::compute_display_setup(const Context& context) const
setup.window_pos.column += overflow; setup.window_pos.column += overflow;
setup.cursor_pos.column -= overflow; setup.cursor_pos.column -= overflow;
} }
check_display_setup(setup, *this);
} }
return setup; return setup;

View File

@ -0,0 +1 @@
<c-l>

View File

@ -0,0 +1,10 @@
1
2
3
4
5
6
7
8
9
10

View File

@ -0,0 +1 @@
add-highlighter window number_lines

View File

@ -0,0 +1 @@
{ "jsonrpc": "2.0", "method": "resize", "params": [ 5, 2 ] }