Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 19 Oct 2014 18:18:32 UTC Commit: 02a773c55c73245b202ae31bab2ea866fbf8da56 https://github.com/geany/geany-plugins/commit/02a773c55c73245b202ae31bab2ea8...
Log Message: ----------- geanyctags: open document automatically only when there is a single result
If there are several results from the ctags search, opening the first document isn't the best thing to do because it's most probably not the tag we are searching for. Instead, don't open the document and just write all the results to the messages window so the user can choose which one to open.
Modified Paths: -------------- geanyctags/src/geanyctags.c
Modified: geanyctags/src/geanyctags.c 28 lines changed, 20 insertions(+), 8 deletions(-) =================================================================== @@ -422,6 +422,8 @@ static void find_tags(const gchar *name, gboolean declaration, gboolean case_sen { GPatternSpec *name_pat; gchar *name_case; + gchar *path = NULL; + gint num = 0;
if (case_sensitive) name_case = g_strdup(name); @@ -433,25 +435,35 @@ static void find_tags(const gchar *name, gboolean declaration, gboolean case_sen
if (!filter_tag(&entry, name_pat, declaration, case_sensitive)) { - gchar *path = g_build_filename(prj->base_path, entry.file, NULL); - GeanyDocument *doc = document_open_file(path, FALSE, NULL, NULL); - if (doc != NULL) - { - navqueue_goto_line(document_get_current(), doc, entry.address.lineNumber); - gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci)); - } + path = g_build_filename(prj->base_path, entry.file, NULL); show_entry(&entry); - g_free(path); + num++; } while (find_next(tf, &entry, match_type)) { if (!filter_tag(&entry, name_pat, declaration, case_sensitive)) + { + if (!path) + path = g_build_filename(prj->base_path, entry.file, NULL); show_entry(&entry); + num++; + } + } + + if (num == 1) + { + GeanyDocument *doc = document_open_file(path, FALSE, NULL, NULL); + if (doc != NULL) + { + navqueue_goto_line(document_get_current(), doc, entry.address.lineNumber); + gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci)); + } }
g_pattern_spec_free(name_pat); g_free(name_case); + g_free(path); }
tagsClose(tf);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org