Report scope including classes, namespaces and alike
Don't only match the current function as the current scope, but also classes, namespaces and others containers. Closes #1996778.
This commit is contained in:
parent
491a45f614
commit
8289e8f962
@ -2204,6 +2204,20 @@ gint symbols_get_current_function(GeanyDocument *doc, const gchar **tagname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* same as symbols_get_current_function() but finds class, namespaces and more */
|
||||||
|
gint symbols_get_current_scope(GeanyDocument *doc, const gchar **tagname)
|
||||||
|
{
|
||||||
|
guint tag_types = (tm_tag_function_t | tm_tag_method_t | tm_tag_class_t |
|
||||||
|
tm_tag_struct_t | tm_tag_enum_t | tm_tag_union_t);
|
||||||
|
|
||||||
|
/* Python parser reports imports as namespaces which confuses the scope detection */
|
||||||
|
if (doc && doc->file_type->lang != filetypes[GEANY_FILETYPES_PYTHON]->lang)
|
||||||
|
tag_types |= tm_tag_namespace_t;
|
||||||
|
|
||||||
|
return get_current_tag_name_cached(doc, tagname, tag_types);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void on_symbol_tree_sort_clicked(GtkMenuItem *menuitem, gpointer user_data)
|
static void on_symbol_tree_sort_clicked(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
{
|
{
|
||||||
gint sort_mode = GPOINTER_TO_INT(user_data);
|
gint sort_mode = GPOINTER_TO_INT(user_data);
|
||||||
|
@ -61,4 +61,6 @@ gboolean symbols_goto_tag(const gchar *name, gboolean definition);
|
|||||||
|
|
||||||
gint symbols_get_current_function(GeanyDocument *doc, const gchar **tagname);
|
gint symbols_get_current_function(GeanyDocument *doc, const gchar **tagname);
|
||||||
|
|
||||||
|
gint symbols_get_current_scope(GeanyDocument *doc, const gchar **tagname);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -272,7 +272,7 @@ static void add_statusbar_statistics(GString *stats_str,
|
|||||||
g_string_append(stats_str, filetypes_get_display_name(doc->file_type));
|
g_string_append(stats_str, filetypes_get_display_name(doc->file_type));
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
symbols_get_current_function(doc, &cur_tag);
|
symbols_get_current_scope(doc, &cur_tag);
|
||||||
g_string_append(stats_str, cur_tag);
|
g_string_append(stats_str, cur_tag);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user