From b4b08d10b4966c73b56c0823fe888117482ac9df Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 7 May 2017 13:15:34 +0100 Subject: [PATCH] Fix assert when wrapping a line that takes more than the full window height --- src/highlighters.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index 46334a23..e956e18a 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -709,6 +709,7 @@ struct WrapHighlighter : Highlighter return; const Buffer& buffer = context.buffer(); + auto cursor = context.selections().main().cursor(); const int tabstop = context.options()["tabstop"].get(); auto line_wrap_count = [&](LineCount line) { @@ -746,7 +747,6 @@ struct WrapHighlighter : Highlighter // Place the cursor correctly after its line gets wrapped else if (win_line == setup.cursor_pos.line) { - auto cursor = context.selections().main().cursor(); BufferCoord coord{buf_line}; while (true) { @@ -764,19 +764,21 @@ struct WrapHighlighter : Highlighter win_line += wrap_count + 1; // scroll window to keep cursor visible, and update range as lines gets removed - while (setup.cursor_pos.line >= win_height) + while (buf_line < cursor.line and setup.cursor_pos.line >= win_height) { auto removed_lines = 1 + line_wrap_count(setup.window_pos.line++); setup.cursor_pos.line -= removed_lines; win_line -= removed_lines; // removed one line from the range, added removed_lines potential ones setup.window_range.line += removed_lines - 1; + kak_assert(setup.cursor_pos.line >= 0); } if (setup.window_range.line <= buf_line - setup.window_pos.line) setup.window_range.line = buf_line - setup.window_pos.line + 1; - - kak_assert(setup.cursor_pos.line >= 0 and setup.cursor_pos.line < win_height); + // Todo: support displaying partial lines, so that we can ensure the cursor is + // visible even if a line takes more than the full screen height once wrapped. + // kak_assert(setup.cursor_pos.line >= 0 and setup.cursor_pos.line < win_height); } }