[gtksourceview] Improved reserving empty lines in handle_text_inserted
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtksourceview] Improved reserving empty lines in handle_text_inserted
- Date: Sat, 2 Jan 2010 13:54:08 +0000 (UTC)
commit 14b9a0b0354783c1fdfb2acaffc0588521cf8cb5
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Sat Jan 2 14:53:32 2010 +0100
Improved reserving empty lines in handle_text_inserted
.../words/gtksourcecompletionwordsbuffer.c | 43 ++++++++++++-------
1 files changed, 27 insertions(+), 16 deletions(-)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
index 023b17b..a116b08 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
@@ -511,33 +511,44 @@ handle_text_inserted (GtkSourceCompletionWordsBuffer *buffer,
{
gint pos = start;
GList *ptr = NULL;
+ GList *newlines = NULL;
+ GList *last = NULL;
+ while (pos < end)
+ {
+ newlines = g_list_prepend (newlines, NULL);
+
+ if (last == NULL)
+ {
+ last = newlines;
+ }
+
+ ++pos;
+ }
+
if (start > end)
{
ptr = g_list_nth (buffer->priv->lines,
start + 1);
}
-
- while (pos < end)
+
+ if (ptr != NULL)
{
- /* Insert new empty lines */
- if (ptr == NULL)
+ if (ptr->prev)
{
- buffer->priv->lines =
- g_list_append (buffer->priv->lines,
- NULL);
- }
- else
- {
- buffer->priv->lines =
- g_list_insert_before (buffer->priv->lines,
- ptr,
- NULL);
+ ptr->prev->next = newlines;
+ newlines->prev = ptr->prev;
}
- ++pos;
+ newlines->next = ptr;
+ ptr->prev = last;
}
-
+ else
+ {
+ buffer->priv->lines = g_list_concat (buffer->priv->lines,
+ newlines);
+ }
+
/* Invalidate new region */
add_scan_region (buffer,
start,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]