[geany/geany] cd1a58: Use language-specific context separator instead of hard-coded "::"
Jiří Techet
git-noreply at xxxxx
Thu Feb 11 14:36:02 UTC 2016
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Mon, 18 Jan 2016 21:56:10 UTC
Commit: cd1a58f0a503f2d18592ebd77a1a7fb104e863cd
https://github.com/geany/geany/commit/cd1a58f0a503f2d18592ebd77a1a7fb104e863cd
Log Message:
-----------
Use language-specific context separator instead of hard-coded "::"
This makes it possible to popup scope completion dialog for more languages.
Modified Paths:
--------------
src/editor.c
tagmanager/src/tm_tag.c
Modified: src/editor.c
25 lines changed, 11 insertions(+), 14 deletions(-)
===================================================================
@@ -713,6 +713,7 @@ static gboolean autocomplete_scope(GeanyEditor *editor, const gchar *root, gsize
gboolean member;
gboolean ret = FALSE;
const gchar *current_scope;
+ const gchar *context_sep = tm_tag_context_separator(ft->lang);
if (autocomplete_scope_shown)
{
@@ -727,21 +728,16 @@ static gboolean autocomplete_scope(GeanyEditor *editor, const gchar *root, gsize
typed = sci_get_char_at(sci, pos - 1);
}
+ /* make sure to keep in sync with similar checks below */
if (typed == '.')
pos -= 1;
- else if (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP ||
- ft->id == GEANY_FILETYPES_PHP || ft->id == GEANY_FILETYPES_RUST)
- {
- if (match_last_chars(sci, pos, "::"))
- pos-=2;
- else if ((ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP) &&
- match_last_chars(sci, pos, "->"))
- pos-=2;
- else if (ft->id == GEANY_FILETYPES_CPP && match_last_chars(sci, pos, "->*"))
- pos-=3;
- else
- return FALSE;
- }
+ else if (match_last_chars(sci, pos, context_sep))
+ pos -= strlen(context_sep);
+ else if ((ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP) &&
+ match_last_chars(sci, pos, "->"))
+ pos -= 2;
+ else if (ft->id == GEANY_FILETYPES_CPP && match_last_chars(sci, pos, "->*"))
+ pos -= 3;
else
return FALSE;
@@ -774,7 +770,8 @@ static gboolean autocomplete_scope(GeanyEditor *editor, const gchar *root, gsize
pos -= strlen(name);
while (pos > 0 && isspace(sci_get_char_at(sci, pos - 1)))
pos--;
- member = match_last_chars(sci, pos, ".") || match_last_chars(sci, pos, "::") ||
+ /* make sure to keep in sync with similar checks above */
+ member = match_last_chars(sci, pos, ".") || match_last_chars(sci, pos, context_sep) ||
match_last_chars(sci, pos, "->") || match_last_chars(sci, pos, "->*");
if (symbols_get_current_scope(editor->document, ¤t_scope) == -1)
Modified: tagmanager/src/tm_tag.c
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -1368,11 +1368,12 @@ void tm_tags_array_print(GPtrArray *tags, FILE *fp)
*/
gint tm_tag_scope_depth(const TMTag *t)
{
+ const gchar *context_sep = tm_tag_context_separator(t->lang);
gint depth;
char *s;
if(!(t && t->scope))
return 0;
- for (s = t->scope, depth = 0; s; s = strstr(s, "::"))
+ for (s = t->scope, depth = 0; s; s = strstr(s, context_sep))
{
++ depth;
++ s;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list