After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 631468 - Inserting split CRLF pair causes GtkTextBuffer lines to get out of sync
Inserting split CRLF pair causes GtkTextBuffer lines to get out of sync
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 621226 632356 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-10-05 20:34 UTC by Kai Willadsen
Modified: 2018-05-02 14:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase (1.14 KB, application/octet-stream)
2010-10-05 20:34 UTC, Kai Willadsen
Details
Testcase (963 bytes, text/plain)
2013-04-03 22:37 UTC, Sébastien Wilmet
Details

Description Kai Willadsen 2010-10-05 20:34:32 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.
Comment 1 Ignacio Casal Quinteiro (nacho) 2010-10-18 12:05:22 UTC
*** Bug 632356 has been marked as a duplicate of this bug. ***
Comment 2 Ignacio Casal Quinteiro (nacho) 2010-10-18 12:08:31 UTC
*** Bug 621226 has been marked as a duplicate of this bug. ***
Comment 3 Sébastien Wilmet 2013-04-03 22:37:00 UTC
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
Comment 4 Sébastien Wilmet 2014-08-20 14:46:28 UTC
See the fixed bug #337022 for a related problem.
Comment 5 Matthias Clasen 2018-02-10 05:07:17 UTC
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.
Comment 6 Sébastien Wilmet 2018-02-10 10:05:08 UTC
Still a problem.
Comment 7 GNOME Infrastructure Team 2018-05-02 14:59:49 UTC
-- 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.