Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Mon, 29 Aug 2022 17:35:46 UTC
Commit: 10fba80d84fa940c10f193bc351f96e2cc32d92b
https://github.com/geany/geany/commit/10fba80d84fa940c10f193bc351f96e2cc32d…
Log Message:
-----------
Ignore local tags for autocompletion in other files
ctags sets the tag's "local" flag to true for tags whose visibility is
limited to the current file only. These are for instance "static" functions
in C.
We can ignore these tags for autocompletion in other files than the
tag's file which reduces the number of irrelevant tags in the
autocompletion popup.
Modified Paths:
--------------
src/tagmanager/tm_workspace.c
Modified: src/tagmanager/tm_workspace.c
7 lines changed, 6 insertions(+), 1 deletions(-)
===================================================================
@@ -637,7 +637,12 @@ gboolean tm_workspace_is_autocomplete_tag(TMTag *tag,
(current_file == tag->file &&
current_line >= tag->line &&
g_strcmp0(current_scope, tag->scope) == 0);
- return valid && !tm_tag_is_anon(tag) && tm_parser_langs_compatible(lang, tag->lang);
+
+ /* tag->local indicates per-file-only visibility such as static C functions */
+ gboolean valid_local = !tag->local || current_file == tag->file;
+
+ return valid && valid_local &&
+ !tm_tag_is_anon(tag) && tm_parser_langs_compatible(lang, tag->lang);
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Thu, 01 Sep 2022 21:05:29 UTC
Commit: b8754a7a32e2972761e07ebb191db44ab01ec6bb
https://github.com/geany/geany/commit/b8754a7a32e2972761e07ebb191db44ab01ec…
Log Message:
-----------
Fix renaming tag type containing anonymous type
The current code assumes that the whole var_type string consists of the
anonymous type name. This works for simple cases like
struct {} X;
where X is of the type __anonXXXX but not for cases like
struct {} X[2];
where X is of type __anonXXXX[].
For these cases checking for equality of var_tag->var_type, orig_name isn't
sufficient and we have to check whether orig_name is a substring
of var_tag->var_type and replace this substring with the new anon name.
This problem can be seen for instance in the symbol tree tooltip of
the symbols_icons variable inside symbols.c
Modified Paths:
--------------
src/tagmanager/tm_ctags.c
Modified: src/tagmanager/tm_ctags.c
12 lines changed, 9 insertions(+), 3 deletions(-)
===================================================================
@@ -380,18 +380,24 @@ static void rename_anon_tags(TMSourceFile *source_file)
}
/* We are out of the nesting - the next tags could be variables
- * of an anonymous struct such as "struct {} a, b;" */
+ * of an anonymous struct such as "struct {} a[2], *b, c;" */
while (j < source_file->tags_array->len)
{
TMTag *var_tag = TM_TAG(source_file->tags_array->pdata[j]);
guint var_scope_len = var_tag->scope ? strlen(var_tag->scope) : 0;
+ gchar *pos;
/* Should be at the same scope level as the anon tag */
if (var_scope_len == scope_len &&
- g_strcmp0(var_tag->var_type, orig_name) == 0)
+ var_tag->var_type && (pos = strstr(var_tag->var_type, orig_name)))
{
+ GString *str = g_string_new(var_tag->var_type);
+ gssize p = pos - var_tag->var_type;
+ g_string_erase(str, p, strlen(orig_name));
+ g_string_insert(str, p, new_name);
g_free(var_tag->var_type);
- var_tag->var_type = g_strdup(new_name);
+ var_tag->var_type = str->str;
+ g_string_free(str, FALSE);
}
else
break;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).