Branch: refs/heads/master
Author: Thomas Martitz <thomas.martitz(a)mailbox.org>
Committer: Thomas Martitz <thomas.martitz(a)mailbox.org>
Date: Sat, 27 Aug 2022 20:27:24 UTC
Commit: 6db1b3a7bdb6680da0f28cfaab8257403ba2b293
https://github.com/geany/geany/commit/6db1b3a7bdb6680da0f28cfaab8257403ba2b…
Log Message:
-----------
Fix intermittent, erratic right-click behavior documents sidebar page
Sometimes right-click to open a the popup menu in the document sidebar
wouldn't change the selection before showing the popup. Then the
popup wasn't related to the document that was clicked.
This was especially bad with middle-click to close. It closed anything
but the clicked document (or folder in case of tree view).
This was caused by some unexpected calls to the "activate" signal handler
for the "openfiles_path_mode" menu items. The handler might re-create
the document list which in turn invalidates the current selection.
Now the signal handler has some protection against unexpected calls and
the selection properly updates upon right-click before spawing the popup.
Modified Paths:
--------------
src/sidebar.c
Modified: src/sidebar.c
17 lines changed, 16 insertions(+), 1 deletions(-)
===================================================================
@@ -1093,7 +1093,22 @@ void sidebar_add_common_menu_items(GtkMenu *menu)
static void on_openfiles_show_paths_activate(GtkCheckMenuItem *item, gpointer user_data)
{
- interface_prefs.openfiles_path_mode = GPOINTER_TO_INT(user_data);
+ gint new_mode = GPOINTER_TO_INT(user_data);
+ /* This is also called for menu items that became inactive (in response to activating
+ * another one in the same group).
+ */
+ if (!gtk_check_menu_item_get_active(item))
+ return;
+
+ /* Only if the mode changes...otherwise sidebar_openfiles_update_all() recreates the
+ * list which messes up the current selection and more.
+ *
+ * This can happen (for example) right after startup, when no menu item was active yet.
+ */
+ if (interface_prefs.openfiles_path_mode == new_mode)
+ return;
+
+ interface_prefs.openfiles_path_mode = new_mode;
sidebar_openfiles_update_all();
gtk_tree_view_expand_all(GTK_TREE_VIEW(tv.tree_openfiles));
sidebar_select_openfiles_item(document_get_current());
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger(a)uvena.de>
Committer: GitHub <noreply(a)github.com>
Date: Sun, 11 Sep 2022 13:50:26 UTC
Commit: 563d94d856ff5ee799f8c8505681ba4544514c33
https://github.com/geany/geany/commit/563d94d856ff5ee799f8c8505681ba4544514…
Log Message:
-----------
Merge pull request #3265 from kugel-/fix-rightclick
Fix intermittent, erratic right-click behavior on documents sidebar page
Modified Paths:
--------------
src/sidebar.c
Modified: src/sidebar.c
17 lines changed, 16 insertions(+), 1 deletions(-)
===================================================================
@@ -1093,7 +1093,22 @@ void sidebar_add_common_menu_items(GtkMenu *menu)
static void on_openfiles_show_paths_activate(GtkCheckMenuItem *item, gpointer user_data)
{
- interface_prefs.openfiles_path_mode = GPOINTER_TO_INT(user_data);
+ gint new_mode = GPOINTER_TO_INT(user_data);
+ /* This is also called for menu items that became inactive (in response to activating
+ * another one in the same group).
+ */
+ if (!gtk_check_menu_item_get_active(item))
+ return;
+
+ /* Only if the mode changes...otherwise sidebar_openfiles_update_all() recreates the
+ * list which messes up the current selection and more.
+ *
+ * This can happen (for example) right after startup, when no menu item was active yet.
+ */
+ if (interface_prefs.openfiles_path_mode == new_mode)
+ return;
+
+ interface_prefs.openfiles_path_mode = new_mode;
sidebar_openfiles_update_all();
gtk_tree_view_expand_all(GTK_TREE_VIEW(tv.tree_openfiles));
sidebar_select_openfiles_item(document_get_current());
--------------
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: Sun, 28 Aug 2022 21:21:46 UTC
Commit: 8c7081c652bd7a932138b749fd4da3731af01f4a
https://github.com/geany/geany/commit/8c7081c652bd7a932138b749fd4da3731af01…
Log Message:
-----------
Don't use temporary file when creating tag files without running preprocessor
The tm_workspace_create_global_tags() function generates tags for
two cases:
1. Source files pre-processed by C pre-processor. It first generates
a file combining the parsed header files by creating a temporary
file in which all the header files are included and this file is passed
to the pre-processor. The result of the pre-processed file is then
parsed by the ctags parser.
2. Source files directly parsed by the ctags parser. In this case all
the source files are concatenated to a single file which is then parsed
by the ctags parser.
This patch leaves (1) more or less unchanged; however, the creation of
the temporary file in (2) is unnecessary - the individual files can
be parsed directly, the tags from all the parses can be combined, sorted
and pruned without creating the temporary file.
The temporary file is a problem for unit tests where some languages
use the file name as the name of module in which the tags are defined
and by using a different name, the unit test generates a different tag
file every time it's run.
Note the changed output of the process_order unit test caused by this
change. The test parses two files, one containing
enum {
I1_E1,
I1_E2,
};
the other contining
enum {
I2_E1,
I2_E2,
};
Previously, because the files were concatenated the enums were different
tags and the anonnymous tag renaming function renamed them to anon_enum_1
and anon_enum_2. Because now the files are parsed separately, the
enum from the first file gets renamed to anon_enum_1 and when parsing
the second file, we get the name anon_enum_1 as well for the second enum.
This however isn't a problem - we don't display global tags in the
symbol tree, autocompletion, and they are also ignored in scope completion
so this shouldn't matter much.
Modified Paths:
--------------
src/tagmanager/tm_workspace.c
tests/ctags/process_order.c.tags
Modified: src/tagmanager/tm_workspace.c
148 lines changed, 76 insertions(+), 72 deletions(-)
===================================================================
@@ -387,40 +387,6 @@ static gboolean write_includes_file(const gchar *outf, GList *includes_files)
return fclose(fp) == 0;
}
-
-static gboolean combine_source_files(const gchar *outf, GList *file_list)
-{
- FILE *fp = g_fopen(outf, "w");
- GList *node = file_list;
-
- if (!fp)
- return FALSE;
-
- while (node)
- {
- const char *fname = node->data;
- char *contents;
- size_t length;
- GError *err = NULL;
-
- if (! g_file_get_contents(fname, &contents, &length, &err))
- {
- fprintf(stderr, "Unable to read file: %s\n", err->message);
- g_error_free(err);
- }
- else
- {
- fwrite(contents, length, 1, fp);
- fwrite("\n", 1, 1, fp); /* in case file doesn't end in newline (e.g. windows). */
- g_free(contents);
- }
- node = g_list_next (node);
- }
-
- return fclose(fp) == 0;
-}
-
-
static gchar *create_temp_file(const gchar *tpl)
{
gchar *name;
@@ -503,57 +469,35 @@ static gchar *pre_process_file(const gchar *cmd, const gchar *inf)
return outf;
}
-/* Creates a list of global tags. Ideally, this should be created once during
- installations so that all users can use the same file. This is because a full
- scale global tag list can occupy several megabytes of disk space.
- @param pre_process_cmd The pre-processing command. This is executed via system(),
- so you can pass stuff like 'gcc -E -dD -P `gnome-config --cflags gnome`'.
- @param sources Source files to process. Wildcards such as '/usr/include/a*.h'
- are allowed.
- @param tags_file The file where the tags will be stored.
- @param lang The language to use for the tags file.
- @return TRUE on success, FALSE on failure.
-*/
-gboolean tm_workspace_create_global_tags(const char *pre_process_cmd, const char **sources,
- int sources_count, const char *tags_file, TMParserType lang)
+static gboolean create_global_tags_preprocessed(const char *pre_process_cmd,
+ GList *source_files, const char *tags_file, TMParserType lang)
{
- gboolean ret = FALSE;
TMSourceFile *source_file;
- GList *source_files;
+ gboolean ret = FALSE;
+ gchar *temp_file2;
gchar *temp_file = create_temp_file("tmp_XXXXXX.cpp");
GPtrArray *filtered_tags;
- if (!temp_file)
- return FALSE;
-
- source_files = lookup_sources(sources, sources_count);
-
#ifdef TM_DEBUG
g_message ("writing out files to %s\n", temp_file);
#endif
- if (pre_process_cmd)
- ret = write_includes_file(temp_file, source_files);
- else
- ret = combine_source_files(temp_file, source_files);
- g_list_free_full(source_files, g_free);
- if (!ret)
+ if (!temp_file)
+ return FALSE;
+
+ if (!write_includes_file(temp_file, source_files))
goto cleanup;
- ret = FALSE;
- if (pre_process_cmd)
- {
- gchar *temp_file2 = pre_process_file(pre_process_cmd, temp_file);
+ temp_file2 = pre_process_file(pre_process_cmd, temp_file);
- if (temp_file2)
- {
- g_unlink(temp_file);
- g_free(temp_file);
- temp_file = temp_file2;
- }
- else
- goto cleanup;
+ if (temp_file2)
+ {
+ g_unlink(temp_file);
+ g_free(temp_file);
+ temp_file = temp_file2;
}
+ else
+ goto cleanup;
source_file = tm_source_file_new(temp_file, tm_source_file_get_lang_name(lang));
if (!source_file)
@@ -577,6 +521,66 @@ gboolean tm_workspace_create_global_tags(const char *pre_process_cmd, const char
return ret;
}
+static gboolean create_global_tags_direct(GList *source_files, const char *tags_file,
+ TMParserType lang)
+{
+ GList *node;
+ GPtrArray *filtered_tags;
+ GPtrArray *tags = g_ptr_array_new();
+ GSList *tm_source_files = NULL;
+ gboolean ret = FALSE;
+
+ for (node = source_files; node; node = node->next)
+ {
+ TMSourceFile *source_file = tm_source_file_new(node->data, tm_source_file_get_lang_name(lang));
+ if (source_file)
+ {
+ guint i;
+ tm_source_files = g_slist_prepend(tm_source_files, source_file);
+ tm_source_file_parse(source_file, NULL, 0, FALSE);
+ for (i = 0; i < source_file->tags_array->len; i++)
+ g_ptr_array_add(tags, source_file->tags_array->pdata[i]);
+ }
+ }
+
+ filtered_tags = tm_tags_extract(tags, ~tm_tag_local_var_t);
+ tm_tags_sort(filtered_tags, global_tags_sort_attrs, TRUE, FALSE);
+
+ if (filtered_tags->len > 0)
+ ret = tm_source_file_write_tags_file(tags_file, filtered_tags);
+
+ g_ptr_array_free(tags, TRUE);
+ g_ptr_array_free(filtered_tags, TRUE);
+ g_slist_free_full(tm_source_files, (GDestroyNotify)tm_source_file_free);
+
+ return ret;
+}
+
+/* Creates a list of global tags. Ideally, this should be created once during
+ installations so that all users can use the same file. This is because a full
+ scale global tag list can occupy several megabytes of disk space.
+ @param pre_process_cmd The pre-processing command. This is executed via system(),
+ so you can pass stuff like 'gcc -E -dD -P `gnome-config --cflags gnome`'.
+ @param sources Source files to process. Wildcards such as '/usr/include/a*.h'
+ are allowed.
+ @param tags_file The file where the tags will be stored.
+ @param lang The language to use for the tags file.
+ @return TRUE on success, FALSE on failure.
+*/
+gboolean tm_workspace_create_global_tags(const char *pre_process_cmd, const char **sources,
+ int sources_count, const char *tags_file, TMParserType lang)
+{
+ gboolean ret = FALSE;
+ GList *source_files = lookup_sources(sources, sources_count);
+
+ if (pre_process_cmd)
+ ret = create_global_tags_preprocessed(pre_process_cmd, source_files, tags_file, lang);
+ else
+ ret = create_global_tags_direct(source_files, tags_file, lang);
+
+ g_list_free_full(source_files, g_free);
+ return ret;
+}
static void fill_find_tags_array(GPtrArray *dst, const GPtrArray *src,
const char *name, const char *scope, TMTagType type, TMParserType lang)
Modified: tests/ctags/process_order.c.tags
10 lines changed, 4 insertions(+), 6 deletions(-)
===================================================================
@@ -2,11 +2,9 @@ I1_E1
enumerator: anon_enum_1 :: I1_E1
I1_E2�4�anon_enum_1�0
enumerator: anon_enum_1 :: I1_E2
-I2_E1�4�anon_enum_2�0
-enumerator: anon_enum_2 :: I2_E1
-I2_E2�4�anon_enum_2�0
-enumerator: anon_enum_2 :: I2_E2
+I2_E1�4�anon_enum_1�0
+enumerator: anon_enum_1 :: I2_E1
+I2_E2�4�anon_enum_1�0
+enumerator: anon_enum_1 :: I2_E2
anon_enum_1�2�1
enum: anon_enum_1 flags: 1
-anon_enum_2�2�1
-enum: anon_enum_2 flags: 1
--------------
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: Sun, 28 Aug 2022 18:40:11 UTC
Commit: 30f5514465e1e98383cff9dc7e88627f13aafd41
https://github.com/geany/geany/commit/30f5514465e1e98383cff9dc7e88627f13aaf…
Log Message:
-----------
Rename variables in tag file writing functions to make things clearer
The code was probably originally written for c/c++ only and all the
mentions of "include files" mean "source files" for other languages.
Modified Paths:
--------------
src/tagmanager/tm_workspace.c
Modified: src/tagmanager/tm_workspace.c
40 lines changed, 20 insertions(+), 20 deletions(-)
===================================================================
@@ -388,7 +388,7 @@ static gboolean write_includes_file(const gchar *outf, GList *includes_files)
}
-static gboolean combine_include_files(const gchar *outf, GList *file_list)
+static gboolean combine_source_files(const gchar *outf, GList *file_list)
{
FILE *fp = g_fopen(outf, "w");
GList *node = file_list;
@@ -435,28 +435,28 @@ static gchar *create_temp_file(const gchar *tpl)
return name;
}
-static GList *lookup_includes(const gchar **includes, gint includes_count)
+static GList *lookup_sources(const gchar **sources, gint sources_count)
{
- GList *includes_files = NULL;
+ GList *source_files = NULL;
GHashTable *table; /* used for deduping */
gint i;
table = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
- for (i = 0; i < includes_count; i++)
+ for (i = 0; i < sources_count; i++)
{
- if (!g_hash_table_lookup(table, includes[i]))
+ if (!g_hash_table_lookup(table, sources[i]))
{
- gchar* file_name_copy = g_strdup(includes[i]);
+ gchar* file_name_copy = g_strdup(sources[i]);
- includes_files = g_list_prepend(includes_files, file_name_copy);
+ source_files = g_list_prepend(source_files, file_name_copy);
g_hash_table_insert(table, file_name_copy, file_name_copy);
}
}
g_hash_table_destroy(table);
- return g_list_reverse(includes_files);
+ return g_list_reverse(source_files);
}
static gchar *pre_process_file(const gchar *cmd, const gchar *inf)
@@ -506,44 +506,44 @@ static gchar *pre_process_file(const gchar *cmd, const gchar *inf)
/* Creates a list of global tags. Ideally, this should be created once during
installations so that all users can use the same file. This is because a full
scale global tag list can occupy several megabytes of disk space.
- @param pre_process The pre-processing command. This is executed via system(),
+ @param pre_process_cmd The pre-processing command. This is executed via system(),
so you can pass stuff like 'gcc -E -dD -P `gnome-config --cflags gnome`'.
- @param includes Include files to process. Wildcards such as '/usr/include/a*.h'
+ @param sources Source files to process. Wildcards such as '/usr/include/a*.h'
are allowed.
@param tags_file The file where the tags will be stored.
@param lang The language to use for the tags file.
@return TRUE on success, FALSE on failure.
*/
-gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
- int includes_count, const char *tags_file, TMParserType lang)
+gboolean tm_workspace_create_global_tags(const char *pre_process_cmd, const char **sources,
+ int sources_count, const char *tags_file, TMParserType lang)
{
gboolean ret = FALSE;
TMSourceFile *source_file;
- GList *includes_files;
+ GList *source_files;
gchar *temp_file = create_temp_file("tmp_XXXXXX.cpp");
GPtrArray *filtered_tags;
if (!temp_file)
return FALSE;
- includes_files = lookup_includes(includes, includes_count);
+ source_files = lookup_sources(sources, sources_count);
#ifdef TM_DEBUG
g_message ("writing out files to %s\n", temp_file);
#endif
- if (pre_process)
- ret = write_includes_file(temp_file, includes_files);
+ if (pre_process_cmd)
+ ret = write_includes_file(temp_file, source_files);
else
- ret = combine_include_files(temp_file, includes_files);
+ ret = combine_source_files(temp_file, source_files);
- g_list_free_full(includes_files, g_free);
+ g_list_free_full(source_files, g_free);
if (!ret)
goto cleanup;
ret = FALSE;
- if (pre_process)
+ if (pre_process_cmd)
{
- gchar *temp_file2 = pre_process_file(pre_process, temp_file);
+ gchar *temp_file2 = pre_process_file(pre_process_cmd, temp_file);
if (temp_file2)
{
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).