[gnome-builder] source-view: use NULL terminated string for insert-text
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] source-view: use NULL terminated string for insert-text
- Date: Mon, 24 Oct 2016 07:21:52 +0000 (UTC)
commit 2e798d89594eab321268e14fc19772ada3b7bbf9
Author: Christian Hergert <chergert redhat com>
Date: Mon Oct 24 00:18:48 2016 -0700
source-view: use NULL terminated string for insert-text
Despite the API providing a text length, we won't necessarily have full
control over plugins, so be more defensive.
libide/sourceview/ide-source-view.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/libide/sourceview/ide-source-view.c b/libide/sourceview/ide-source-view.c
index e9b2176..437e4fe 100644
--- a/libide/sourceview/ide-source-view.c
+++ b/libide/sourceview/ide-source-view.c
@@ -1808,7 +1808,7 @@ ide_source_view_maybe_insert_match (IdeSourceView *self,
GtkTextIter prev_iter;
GtkTextIter next_iter;
gunichar next_ch = 0;
- gchar ch = 0;
+ gchar ch[2] = { 0 };
/*
* TODO: I think we should put this into a base class for auto
@@ -1846,19 +1846,19 @@ ide_source_view_maybe_insert_match (IdeSourceView *self,
switch (event->keyval)
{
case GDK_KEY_braceleft:
- ch = '}';
+ ch[0] = '}';
break;
case GDK_KEY_parenleft:
- ch = ')';
+ ch[0] = ')';
break;
case GDK_KEY_bracketleft:
- ch = ']';
+ ch[0] = ']';
break;
case GDK_KEY_quotedbl:
- ch = '"';
+ ch[0] = '"';
break;
#if 0
@@ -1899,7 +1899,7 @@ ide_source_view_maybe_insert_match (IdeSourceView *self,
* even number on this line. However, if it was the first quote on
* the line, we still need to include a second.
*/
- if (ch == '"')
+ if (ch[0] == '"')
{
guint count;
@@ -1908,7 +1908,7 @@ ide_source_view_maybe_insert_match (IdeSourceView *self,
return FALSE;
}
- gtk_text_buffer_insert_at_cursor (buffer, &ch, 1);
+ gtk_text_buffer_insert_at_cursor (buffer, ch, 1);
gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
gtk_text_iter_backward_char (&iter);
gtk_text_buffer_select_range (buffer, &iter, &iter);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]