Fix mem leak in auto completion and prevent completion of words with trailing spaces.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1630 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2007-06-18 13:22:15 +00:00
parent 35089da654
commit dede8715a2
2 changed files with 13 additions and 8 deletions

View File

@ -1,6 +1,8 @@
2007-06-18 Enrico Tröger <enrico.troeger@uvena.de> 2007-06-18 Enrico Tröger <enrico.troeger@uvena.de>
* scintilla/*, scintilla/include/*: Updated Scintilla to version 1.74. * 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@uvena.de> 2007-06-17 Enrico Tröger <enrico.troeger@uvena.de>

View File

@ -1207,7 +1207,7 @@ static gboolean at_eol(ScintillaObject *sci, gint pos)
gboolean editor_auto_forif(gint idx, gint pos) gboolean editor_auto_forif(gint idx, gint pos)
{ {
gboolean result; gboolean result = FALSE;
gchar *word; gchar *word;
gint lexer, style; gint lexer, style;
gint i; gint i;
@ -1241,17 +1241,20 @@ gboolean editor_auto_forif(gint idx, gint pos)
while (i >= 0 && word[i] != '\n' && word[i] != '\r') // we want to stay in this line('\n' check) while (i >= 0 && word[i] != '\n' && word[i] != '\r') // we want to stay in this line('\n' check)
{ {
if (! isspace(word[i])) if (! isspace(word[i]))
{
g_free(word);
return FALSE; return FALSE;
}
i--; i--;
} }
// get the indentation // prevent completion of "for "
if (doc_list[idx].auto_indent) if (! isspace(sci_get_char_at(sci, pos - 1))) // pos points to the line end char so use pos -1
get_indent(sci, pos, TRUE); {
sci_start_undo_action(sci); // needed because we insert a space separately from construct
sci_start_undo_action(sci); // needed because we insert a space separately from construct result = ac_complete_constructs(idx, pos, word);
result = ac_complete_constructs(idx, pos, word); sci_end_undo_action(sci);
sci_end_undo_action(sci); }
utils_free_pointers(word, NULL); utils_free_pointers(word, NULL);
return result; return result;