SF.net SVN: geany: [1630] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Mon Jun 18 13:22:16 UTC 2007


Revision: 1630
          http://svn.sourceforge.net/geany/?rev=1630&view=rev
Author:   eht16
Date:     2007-06-18 06:22:15 -0700 (Mon, 18 Jun 2007)

Log Message:
-----------
Fix mem leak in auto completion and prevent completion of words with trailing spaces.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/editor.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-06-18 13:02:34 UTC (rev 1629)
+++ trunk/ChangeLog	2007-06-18 13:22:15 UTC (rev 1630)
@@ -1,6 +1,8 @@
 2007-06-18  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * scintilla/*, scintilla/include/*: Updated Scintilla to version 1.74.
+ * src/editor.c: Fix mem leak in auto completion and prevent completion
+                 of words with trailing spaces.
 
 
 2007-06-17  Enrico Tröger  <enrico.troeger at uvena.de>

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2007-06-18 13:02:34 UTC (rev 1629)
+++ trunk/src/editor.c	2007-06-18 13:22:15 UTC (rev 1630)
@@ -1207,7 +1207,7 @@
 
 gboolean editor_auto_forif(gint idx, gint pos)
 {
-	gboolean result;
+	gboolean result = FALSE;
 	gchar *word;
 	gint lexer, style;
 	gint i;
@@ -1241,18 +1241,21 @@
 	while (i >= 0 && word[i] != '\n' && word[i] != '\r') // we want to stay in this line('\n' check)
 	{
 		if (! isspace(word[i]))
+		{
+			g_free(word);
 			return FALSE;
+		}
 		i--;
 	}
 
-	// get the indentation
-	if (doc_list[idx].auto_indent)
-		get_indent(sci, pos, TRUE);
+	// prevent completion of "for "
+	if (! isspace(sci_get_char_at(sci, pos - 1))) // pos points to the line end char so use pos -1
+	{
+		sci_start_undo_action(sci);	// needed because we insert a space separately from construct
+		result = ac_complete_constructs(idx, pos, word);
+		sci_end_undo_action(sci);
+	}
 
-	sci_start_undo_action(sci);	// needed because we insert a space separately from construct
-	result = ac_complete_constructs(idx, pos, word);
-	sci_end_undo_action(sci);
-
 	utils_free_pointers(word, NULL);
 	return result;
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list