Revision: 3698 http://geany.svn.sourceforge.net/geany/?rev=3698&view=rev Author: eht16 Date: 2009-04-07 22:09:08 +0000 (Tue, 07 Apr 2009)
Log Message: ----------- Prevent showing an empty macro list. Show only macros of the same filetype instead of all macros of all loaded filetypes.
Modified Paths: -------------- trunk/ChangeLog trunk/src/editor.c trunk/src/symbols.c trunk/src/symbols.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-04-07 22:08:50 UTC (rev 3697) +++ trunk/ChangeLog 2009-04-07 22:09:08 UTC (rev 3698) @@ -6,6 +6,10 @@ * src/editor.c, src/sciwrappers.c, src/sciwrapper.h: Make editor_highlight_braces() static. Remove unused wrapper functions. + * src/editor.c, src/symbols.c, src/symbols.h: + Prevent showing an empty macro list. + Show only macros of the same filetype instead of all macros of all + loaded filetypes.
2009-04-07 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/editor.c =================================================================== --- trunk/src/editor.c 2009-04-07 22:08:50 UTC (rev 3697) +++ trunk/src/editor.c 2009-04-07 22:09:08 UTC (rev 3698) @@ -1626,7 +1626,7 @@ g_return_val_if_fail(G_LIKELY(editor != NULL), FALSE);
if (G_UNLIKELY(editor->document->file_type != NULL)) - return; + return FALSE;
/* If we are at the beginning of the document, we skip autocompletion as we can't determine the * necessary styling information */ @@ -2125,10 +2125,10 @@ { GString *words;
- if (G_UNLIKELY(editor == NULL)) + if (G_UNLIKELY(editor == NULL) || G_UNLIKELY(editor->document->file_type == NULL)) return;
- words = symbols_get_macro_list(); + words = symbols_get_macro_list(editor->document->file_type->lang); if (G_UNLIKELY(words == NULL)) return;
Modified: trunk/src/symbols.c =================================================================== --- trunk/src/symbols.c 2009-04-07 22:08:50 UTC (rev 3697) +++ trunk/src/symbols.c 2009-04-07 22:09:08 UTC (rev 3698) @@ -274,11 +274,13 @@ }
-GString *symbols_get_macro_list(void) +GString *symbols_get_macro_list(gint lang) { guint j, i; GPtrArray *ftags; GString *words; + gint tag_lang; + TMTag *tag;
if (G_UNLIKELY(app->tm_workspace->work_objects == NULL)) return NULL; @@ -296,11 +298,24 @@ { for (i = 0; ((i < tags->len) && (i < editor_prefs.autocompletion_max_entries)); ++i) { - g_ptr_array_add(ftags, (gpointer) tags->pdata[i]); + tag = TM_TAG(tags->pdata[i]); + tag_lang = (tag->atts.entry.file) ? + tag->atts.entry.file->lang : tag->atts.file.lang; + + if (tag_lang == lang) + g_ptr_array_add(ftags, (gpointer) tags->pdata[i]); } g_ptr_array_free(tags, TRUE); } } + + if (ftags->len == 0) + { + g_ptr_array_free(ftags, TRUE); + g_string_free(words, TRUE); + return NULL; + } + tm_tags_sort(ftags, NULL, FALSE); for (j = 0; j < ftags->len; j++) {
Modified: trunk/src/symbols.h =================================================================== --- trunk/src/symbols.h 2009-04-07 22:08:50 UTC (rev 3697) +++ trunk/src/symbols.h 2009-04-07 22:09:08 UTC (rev 3698) @@ -49,7 +49,7 @@
const GList *symbols_get_tag_list(GeanyDocument *doc, guint tag_types);
-GString *symbols_get_macro_list(void); +GString *symbols_get_macro_list(gint lang);
const gchar **symbols_get_html_entities(void);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.