[TextView] Problems with `*_tag_toggle` when equal tags are followed

,

Inside a TextView i a have a line with two conseciteves texts
where the first text is assigned a tag1 and the second text a tag2:

gtk_text_buffer_insert_with_tags(buffer, &start, "text1", 5, tag1, NULL);
gtk_text_buffer_insert_with_tags(buffer, &start, "text2", 5, tag2, NULL);
|tag1|tag2|
|----|----|
text1text2

if I use the gtk_text_iter_forward_to_tag_toggle i can get where each tag starts/ends

gtk_text_buffer_get_iter_at_line(buffer, &iter, 0);

while (gtk_text_iter_forward_to_tag_toggle(&iter, NULL));
	g_print("Tag End At Position: %d\n", gtk_text_iter_get_offset(&iter));

Tag End At Position: 5
Tag End At Position: 10

this case is OK


the problem is when texts with the same tag are followed:

gtk_text_buffer_insert_with_tags(buffer, &start, "text1", 5, tag1, NULL);
gtk_text_buffer_insert_with_tags(buffer, &start, "text2", 5, tag1, NULL);
|tag1|tag1|
|----|----|
text1text2

when using gtk_text_iter_forward_to_tag_toggle I take the line as if it were a unique tag :no_entry_sign:

Tag End At Position: 10

I expected it to return the same as the previous case: :white_check_mark:

Tag End At Position: 5
Tag End At Position: 10


I leave the source code with which I am testing in case someone can help me: https://pastebin.com/raw/hihtFVXY

I would appreciate any help :smiley:

@ebassi via #gtk:gnome.org:

In the sense that GtkTextBuffer has always done that, and it won’t likely change

TextBuffer will coalesce the boundaries of the tag, if you’re applying the same tag

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.