From 17b19dc057a33b3a2284e6366f1842822bc83c02 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 6 May 2017 19:43:12 +0100 Subject: [PATCH] Ensure window position line is inside buffer --- src/window.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/window.cc b/src/window.cc index 21f3ed74e..47a52fcf7 100644 --- a/src/window.cc +++ b/src/window.cc @@ -185,9 +185,9 @@ void Window::compute_display_setup(const Context& context) // Ensure cursor line is visible if (cursor.line - offset.line < m_position.line) - m_position.line = cursor.line - offset.line; + m_position.line = std::max(0_line, cursor.line - offset.line); if (cursor.line + offset.line >= m_position.line + m_dimensions.line) - m_position.line = cursor.line + offset.line - m_dimensions.line + 1; + m_position.line = std::min(buffer().line_count()-1, cursor.line + offset.line - m_dimensions.line + 1); const int tabstop = context.options()["tabstop"].get(); auto cursor_col = get_column(buffer(), tabstop, cursor);