[geany/geany] b116a6: symbols: provide a bit more path information in the goto-symbol popup.
Thomas Martitz
git-noreply at xxxxx
Mon Dec 3 20:51:01 UTC 2018
Branch: refs/heads/master
Author: Thomas Martitz <kugel at rockbox.org>
Committer: Thomas Martitz <kugel at rockbox.org>
Date: Mon, 03 Dec 2018 20:51:01 UTC
Commit: b116a66862eb89b0c12833eb9bc6ecafcb6c7284
https://github.com/geany/geany/commit/b116a66862eb89b0c12833eb9bc6ecafcb6c7284
Log Message:
-----------
symbols: provide a bit more path information in the goto-symbol popup.
>From #1069:
> At the moment if symbols of the same name are defined in identically named
> files, it's hard to distinguish which file is which because there's no path
> in the popup.
> The popup should show part of the path until a directory where the paths
> differ so it's possible to distinguish the different files. At the same time
> there should probably be some top limit for the length of the paths as they
> can make the popup too wide.
This addresses the above by showing more of the file's paths but still try
to make it as short as possible. The file list is processed by the new
utils_strv_shorten_file_list(), as a result the popup will list files with
the common prefix stripped and the longest common sub-path ellipsized.
As a result, the file list shows enough of the path to make them unique but
still is still very short and doesn't make the dialog too wide.
Fixes #1069.
Modified Paths:
--------------
src/symbols.c
src/utils.c
Modified: src/symbols.c
13 lines changed, 11 insertions(+), 2 deletions(-)
===================================================================
@@ -1933,15 +1933,23 @@ static void show_goto_popup(GeanyDocument *doc, GPtrArray *tags, gboolean have_b
GdkEventButton *button_event = NULL;
TMTag *tmtag;
guint i;
-
+ gchar **short_names, **file_names, **p;
menu = gtk_menu_new();
+ /* If popup would show multiple files presend a smart file list that allows
+ * to easily distinguish the files while avoiding the file paths in their entirety */
+ file_names = g_new(gchar *, tags->len);
+ foreach_ptr_array(tmtag, i, tags)
+ file_names[i] = tmtag->file->file_name;
+ short_names = utils_strv_shorten_file_list(file_names, tags->len);
+ g_free(file_names);
+
foreach_ptr_array(tmtag, i, tags)
{
GtkWidget *item;
GtkWidget *label;
GtkWidget *image;
- gchar *fname = g_path_get_basename(tmtag->file->file_name);
+ gchar *fname = short_names[i];
gchar *text;
if (! first && have_best)
@@ -1964,6 +1972,7 @@ static void show_goto_popup(GeanyDocument *doc, GPtrArray *tags, gboolean have_b
g_free(text);
g_free(fname);
}
+ g_free(short_names);
gtk_widget_show_all(menu);
Modified: src/utils.c
9 lines changed, 3 insertions(+), 6 deletions(-)
===================================================================
@@ -2146,7 +2146,7 @@ gchar *utils_strv_find_lcs(gchar **strv, size_t num)
}
-/** Transform file names in a list to be shorter.
+/* * Transform file names in a list to be shorter.
*
* This function takes a list of file names (porbably with absolute paths), and
* transforms the paths such that they are short but still unique. This is intended
@@ -2156,13 +2156,10 @@ gchar *utils_strv_find_lcs(gchar **strv, size_t num)
* The algorthm strips the common prefix (e-g. the user's home directory) and
* replaces the longest common substring with "...".
*
- * @param file_names @arraylen{num} The list of strings to process.
+ * @param file_names The list of strings to process.
* @param num The number of strings contained in @a strv. Can be 0 if @a strv is a @c GStrv
- * @return @transfer{full} A newly-allocated NULL-terminated array of transformed paths strings. Use @c g_strfreev() to free it.
- *
- * @since 1.31 (API 232
+ * @return A newly-allocated NULL-terminated array of transformed paths strings. Use @c g_strfreev() to free it.
*/
-GEANY_API_SYMBOL
gchar **utils_strv_shorten_file_list(gchar **file_names, size_t num)
{
gint i, j;
--------------
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