Add a static global variable to monitor autocompletion mode in order to prevent cancellation of the struct/class (C/C++) auto completion list (patch by Thomas Martitz, thanks).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4840 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2010-04-19 20:42:44 +00:00
parent fd6bf166af
commit c499da1b4d
2 changed files with 20 additions and 1 deletions

View File

@ -6,6 +6,10 @@
* src/sidebar.c: * src/sidebar.c:
Automatically show and hide the sidebar notebook tabs according Automatically show and hide the sidebar notebook tabs according
to the amount of visible pages (patch by Adrian Dimitrov, thanks). to the amount of visible pages (patch by Adrian Dimitrov, thanks).
* src/editor.c:
Add a static global variable to monitor autocompletion mode in order
to prevent cancellation of the struct/class (C/C++) auto completion
list (patch by Thomas Martitz, thanks).
2010-04-19 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2010-04-19 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -88,6 +88,14 @@ static struct
ScintillaObject *sci; ScintillaObject *sci;
} calltip = {NULL, FALSE, NULL, 0, 0, NULL}; } calltip = {NULL, FALSE, NULL, 0, 0, NULL};
static enum
{
AUTOC_CANCELLED,
AUTOC_SCOPE,
AUTOC_TAGS,
AUTOC_DOC_WORDS,
} autocompletion_mode = AUTOC_CANCELLED;
static gchar indent[100]; static gchar indent[100];
@ -597,7 +605,10 @@ static void autocomplete_scope(GeanyEditor *editor)
tags = tm_workspace_find_scope_members(obj ? obj->tags_array : NULL, tags = tm_workspace_find_scope_members(obj ? obj->tags_array : NULL,
name, TRUE, FALSE); name, TRUE, FALSE);
if (tags) if (tags)
{
autocompletion_mode = AUTOC_SCOPE;
show_tags_list(editor, tags, 0); show_tags_list(editor, tags, 0);
}
} }
} }
@ -932,6 +943,7 @@ static gboolean on_editor_notify(G_GNUC_UNUSED GObject *object, GeanyEditor *edi
case SCN_AUTOCCANCELLED: case SCN_AUTOCCANCELLED:
/* now that autocomplete is finishing or was cancelled, reshow calltips /* now that autocomplete is finishing or was cancelled, reshow calltips
* if they were showing */ * if they were showing */
autocompletion_mode = AUTOC_CANCELLED;
request_reshowing_calltip(nt); request_reshowing_calltip(nt);
break; break;
@ -1775,6 +1787,7 @@ autocomplete_tags(GeanyEditor *editor, const gchar *root, gsize rootlen)
tags = tm_workspace_find(root, tm_tag_max_t, attrs, TRUE, doc->file_type->lang); tags = tm_workspace_find(root, tm_tag_max_t, attrs, TRUE, doc->file_type->lang);
if (tags) if (tags)
{ {
autocompletion_mode = AUTOC_TAGS;
show_tags_list(editor, tags, rootlen); show_tags_list(editor, tags, rootlen);
return tags->len > 0; return tags->len > 0;
} }
@ -1884,6 +1897,7 @@ static gboolean autocomplete_doc_word(GeanyEditor *editor, gchar *root, gsize ro
if (!words) if (!words)
{ {
scintilla_send_message(sci, SCI_AUTOCCANCEL, 0, 0); scintilla_send_message(sci, SCI_AUTOCCANCEL, 0, 0);
autocompletion_mode = AUTOC_CANCELLED;
return FALSE; return FALSE;
} }
@ -1913,6 +1927,7 @@ static gboolean autocomplete_doc_word(GeanyEditor *editor, gchar *root, gsize ro
g_slist_free(list); g_slist_free(list);
g_string_free(words, TRUE); g_string_free(words, TRUE);
autocompletion_mode = AUTOC_DOC_WORDS;
show_autocomplete(sci, rootlen, str->str); show_autocomplete(sci, rootlen, str->str);
g_string_free(str, TRUE); g_string_free(str, TRUE);
return TRUE; return TRUE;
@ -1972,7 +1987,7 @@ gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean forc
root = linebuf + startword; root = linebuf + startword;
rootlen = current - startword; rootlen = current - startword;
if (rootlen > 0) if (rootlen > 0 && autocompletion_mode != AUTOC_SCOPE)
{ {
if (autocomplete_check_for_html(ft->id, style)) if (autocomplete_check_for_html(ft->id, style))
{ {