[gnome-builder] libide: remove empty lines from join
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: remove empty lines from join
- Date: Tue, 24 Mar 2015 00:12:28 +0000 (UTC)
commit acdf2ae9d6d4f00928271e9863c2791724d6e9b9
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 11 15:06:54 2015 -0700
libide: remove empty lines from join
libide/ide-source-view.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 6ccb816..846e2ae 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -2202,6 +2202,31 @@ ide_source_view_real_insert_modifier (IdeSourceView *self,
gtk_text_buffer_end_user_action (buffer);
}
+static gchar **
+remove_empty_lines (gchar **lines)
+{
+ GPtrArray *ar;
+ gsize i = 0;
+
+ g_assert (lines);
+
+ ar = g_ptr_array_new ();
+
+ for (i = 0; lines [i]; i++)
+ {
+ if (lines [i][0])
+ g_ptr_array_add (ar, lines [i]);
+ else
+ g_free (lines [i]);
+ }
+
+ g_ptr_array_add (ar, NULL);
+
+ g_free (lines);
+
+ return (gchar **)g_ptr_array_free (ar, FALSE);
+}
+
static void
ide_source_view_real_join_lines (IdeSourceView *self)
{
@@ -2234,6 +2259,8 @@ ide_source_view_real_join_lines (IdeSourceView *self)
for (i = 1; lines [i]; i++)
g_strstrip (lines [i]);
+ lines = remove_empty_lines (lines);
+
text = g_strchomp (g_strjoinv (" ", lines));
g_strfreev (lines);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]