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 491207 - gtk_text_buffer_delete_interactive() robustness against custom ::delete
gtk_text_buffer_delete_interactive() robustness against custom ::delete
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2007-10-28 22:23 UTC by Owen Taylor
Modified: 2007-10-28 22:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch fixing the problem (1.30 KB, patch)
2007-10-28 22:25 UTC, Owen Taylor
none Details | Review

Description Owen Taylor 2007-10-28 22:23:50 UTC
Say that you had a text buffer, and hooked up a ::insert-text handler so
that for every a typed in the buffer, you inserted a non-editable
b after it.

 (Saby thabt you habd ab text buffer abd ..)

And then you wanted to hook up a ::delete-range handler so that when
an a was deleted, you deleted the b.

Right now, what happens is that this confuses the logic in delete_interactive()

Say the user deletes the range:

 [Saby] that you

First ::delete-range is called for [Sa]. The ::delete-range handler
deletes the text, and the following b, so the next segment to process
is [y]. But delete interactive is hardcoded to think that after it's
called ::delete-range, the next segment is not-editable (it's assuming
that ::delete-range doesn't affect the alternation of editable and
non-editable.)

I'll attach a patch to fix this by simply requerying for the editable
status after each call to ::delete-range.
Comment 1 Owen Taylor 2007-10-28 22:25:27 UTC
Created attachment 98052 [details] [review]
Patch fixing the problem
Comment 2 Owen Taylor 2007-10-28 22:30:34 UTC
Committing immediately. If you are reading this, and actually were
going to review the patch, you can still do so!

2007-10-28  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktextbuffer.c (gtk_text_buffer_delete_interactive): Allow
        the ::delete-range handler to delete text after the text it was
        explicitly asked to delete without confusing us as to whether
        we're currently on an editable or not-editable segment.
        (#491207)