Commit fe0049a3 authored by Kai Willadsen's avatar Kai Willadsen Committed by Christian Hergert

SpaceDrawer: Avoid repeatedly checking last line

The iteration logic for drawing spaces doesn't take into account the
last line in the file, such that the last line always iterates across
the entire length of the line, performing expensive GtkTextIter
operations, even though it's already progressed past the end of the
visible line. This causes problems on files with very long lines as the
last line in the file, which is common on e.g., normal UTF-8 that's been
incorrectly decoded as UTF-16.

The fix here just checks to see whether the forward-to-next-line case
actually forwards to a new line.
parent 221d02bf
......@@ -1433,7 +1433,13 @@ _gtk_source_space_drawer_draw (GtkSourceSpaceDrawer *drawer,
*/
if (!gtk_text_iter_starts_line (&next_iter))
{
gtk_text_iter_forward_line (&next_iter);
/* We're trying to move forward on the last
* line of the buffer, so we can stop now.
*/
if (!gtk_text_iter_forward_line (&next_iter))
{
break;
}
}
gtk_text_view_get_line_yrange (text_view, &next_iter, &ly, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment