diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-05-19 10:46:23 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-05-19 14:15:16 +1000 |
| commit | c9a8658671fd3f985bae9eaeddba8d2b9205573a (patch) | |
| tree | e799bb0c747d838cdb22f2e9a4fee777492b4efc /src | |
| parent | a64afd7f1a92a55572d3d63d2c45ab86da6a51b0 (diff) | |
Fix assert with window small enough so that no part of buffer is displayed
Fixes #2056
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 4 | ||||
| -rw-r--r-- | src/window.cc | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index d1425f39..eafe8a4f 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1064,7 +1064,7 @@ private: return; 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 @@ -1347,7 +1347,7 @@ private: return; } - setup.window_range.column -= width; + setup.window_range.column -= std::min(width, setup.window_range.column); } String m_option_name; diff --git a/src/window.cc b/src/window.cc index a57e7426..43ee52db 100644 --- a/src/window.cc +++ b/src/window.cc @@ -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 { 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 }) m_builtin_highlighters.compute_display_setup({context, pass, {}}, setup); + check_display_setup(setup, *this); // 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.cursor_pos.column -= overflow; } + check_display_setup(setup, *this); } return setup; |
