Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Thomas Martitz thomas.martitz@mailbox.org Date: Sat, 27 Aug 2022 22:44:12 UTC Commit: 13bdb37cf7496a27b0b77c9893839c0fc3aba186 https://github.com/geany/geany/commit/13bdb37cf7496a27b0b77c9893839c0fc3aba1...
Log Message: ----------- Update goto symbol definitions to take into account local variables
We only want to use local variables within the current function for the goto. This means we want to filter out local variable tags that: 1. Are from a different file 2. Are declared later in the file than where the current cursor is 3. Have different scope than the current function scope
Fundamentally the same requirements as for (non-scope) autocompletion.
Modified Paths: -------------- src/symbols.c
Modified: src/symbols.c 10 lines changed, 10 insertions(+), 0 deletions(-) =================================================================== @@ -1597,13 +1597,23 @@ static TMTag *find_best_goto_tag(GeanyDocument *doc, GPtrArray *tags)
static GPtrArray *filter_tags(GPtrArray *tags, TMTag *current_tag, gboolean definition) { + GeanyDocument *doc = document_get_current(); + guint current_line = sci_get_current_line(doc->editor->sci) + 1; const TMTagType forward_types = tm_tag_prototype_t | tm_tag_externvar_t; TMTag *tmtag, *last_tag = NULL; + const gchar *current_scope = NULL; GPtrArray *filtered_tags = g_ptr_array_new(); guint i;
+ symbols_get_current_function(doc, ¤t_scope); + foreach_ptr_array(tmtag, i, tags) { + /* don't show local variables outside current function or other + * irrelevant tags - same as in the autocomplete case */ + if (!tm_workspace_is_autocomplete_tag(tmtag, doc->tm_file, current_line, current_scope)) + continue; + if ((definition && !(tmtag->type & forward_types)) || (!definition && (tmtag->type & forward_types))) {
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).