GNOME Bugzilla – Bug 631468
Inserting split CRLF pair causes GtkTextBuffer lines to get out of sync
Last modified: 2018-05-02 14:59:49 UTC
Created attachment 171788 [details] Testcase When inserting text into a GtkTextBuffer, a gtk_text_buffer_insert where the string ends in '\r' and the next _insert string starts in '\n' gives different (incorrect) results to inserting the '\r\n' as a pair. Specifically, inserting '\r' creates an additional line in the GtkTextBuffer, which is not retroactively adjusted for when the second half of the split CRLF pair is inserted. There is no visible symptom of this in the corresponding GtkTextView, but any code that relies on GtkTextBuffer line indices will break. In the real world, a split pair can be inserted when, for example, reading from a file in 4K chunks and inserting each chunk into the buffer. If a '\r\n' pair occurs on the split between chunk boundaries, bad things happen. A minimal testcase is attached. Apologies for the terrible C---it's a quick port from a Python testcase---but it illustrates the point.
*** Bug 632356 has been marked as a duplicate of this bug. ***
*** Bug 621226 has been marked as a duplicate of this bug. ***
Created attachment 240553 [details] Testcase Clearer testcase. Output (char #13 is \r, char #10 is \n): Inserting split pair char #97 at line 0 char #13 at line 0 char #10 at line 1 char #98 at line 2 Inserting joined pair char #97 at line 0 char #13 at line 0 char #10 at line 0 char #98 at line 1
See the fixed bug #337022 for a related problem.
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Still a problem.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/345.