diff options
author | Christian Hergert <chergert@redhat.com> | 2022-08-02 16:01:01 -0700 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2022-08-02 22:16:10 -0700 |
commit | 4f223a98a2168161b534a984e07ed7e58f0bb3b6 (patch) | |
tree | fe02e68094e0d6fc3f6a461e5a5955964910f988 | |
parent | 8580818311446ecb2e5e6b783ae4c2f0d3dbda0b (diff) | |
download | gtksourceview-wip/chergert/backport-fixes-for-pathological-data.tar.gz |
bufferoutputstream: handle pathalogical fallback casewip/chergert/backport-fixes-for-pathological-data
Avoid inserting really long lines in pathalogical insert_fallback() cases.
This helps keep rendering performance okay in the presence of us inserting
a bunch of fallback characters.
Related #284
-rw-r--r-- | gtksourceview/gtksourcebufferoutputstream.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gtksourceview/gtksourcebufferoutputstream.c b/gtksourceview/gtksourcebufferoutputstream.c index 44d6f7fa..2756a3c0 100644 --- a/gtksourceview/gtksourcebufferoutputstream.c +++ b/gtksourceview/gtksourcebufferoutputstream.c @@ -615,7 +615,17 @@ insert_fallback (GtkSourceBufferOutputStream *stream, for (gsize i = 0; i < count; i++) { guint8 c = ((const guint8 *)buffer)[i]; + g_string_append_len (str, hex_fallback[c], 3); + + /* Add an occasional newline so that we are more + * likely to not tank app performance. + */ + if ((i+1) % 80 == 0) + { + g_string_append_c (str, '\n'); + } + } gtk_text_buffer_insert (GTK_TEXT_BUFFER (stream->priv->source_buffer), |