[gtksourceview/wip/chergert/vim: 209/363] buffer: keep start and end valid across calls
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 209/363] buffer: keep start and end valid across calls
- Date: Mon, 8 Nov 2021 19:53:51 +0000 (UTC)
commit 2f3ac37b23b2fc0897ac7ef2a67373b224d6d3ca
Author: Christian Hergert <chergert redhat com>
Date: Tue Nov 2 13:49:28 2021 -0700
buffer: keep start and end valid across calls
To ensure that the caller can continue to use @start and @end, we need to
update the text iters to surround the new text. This allows the caller to
perform further modifications after changing the case.
gtksourceview/gtksourcebuffer.c | 7 +++++++
1 file changed, 7 insertions(+)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index b7f8ce53..ae576739 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -2486,6 +2486,9 @@ do_title_case (GtkTextBuffer *buffer,
*
* Changes the case of the text between the specified iterators.
*
+ * Since 5.4, this function will update the position of @start and
+ * @end to surround the modified text.
+ *
* Since: 3.12
*/
void
@@ -2532,6 +2535,10 @@ gtk_source_buffer_change_case (GtkSourceBuffer *buffer,
gtk_text_buffer_insert (text_buffer, start, new_text, -1);
gtk_text_buffer_end_user_action (text_buffer);
+ /* Leave @start and @end in valid positions around the text */
+ *end = *start;
+ gtk_text_iter_backward_chars (start, g_utf8_strlen (new_text, -1));
+
g_free (new_text);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]