I've been running this (well, almost… see below :grin:) for a couple days and 
it seems to work nicely

My "small" patch on top just because:
```diff
diff --git a/src/tagmanager/tm_ctags.c b/src/tagmanager/tm_ctags.c
index a5cb9531e..16e2ebf04 100644
--- a/src/tagmanager/tm_ctags.c
+++ b/src/tagmanager/tm_ctags.c
@@ -119,12 +119,7 @@ static gboolean init_tag(TMTag *tag, TMSourceFile *file, 
const tagEntryInfo *tag
 
        tag->name = g_strdup(tag_entry->name);
        tag->type = type;
-       /* ctags sets "isFileScope" also for files with an unknown extension -
-        * make sure we set "local" only for files with a known C/C++ extension 
*/
-       if (file->lang == TM_PARSER_C || file->lang == TM_PARSER_CPP)
-               tag->local = tag_entry->isFileScope && file->is_c_source;
-       else
-               tag->local = tag_entry->isFileScope;
+       tag->local = tag_entry->isFileScope && file->trust_file_scope;
        tag->flags = tm_tag_flag_none_t;
        if (isTagExtraBitMarked(tag_entry, XTAG_ANONYMOUS))
                tag->flags |= tm_tag_flag_anon_t;
diff --git a/src/tagmanager/tm_source_file.c b/src/tagmanager/tm_source_file.c
index 599ae4fa7..e5a27419b 100644
--- a/src/tagmanager/tm_source_file.c
+++ b/src/tagmanager/tm_source_file.c
@@ -609,20 +609,28 @@ static gboolean tm_source_file_init(TMSourceFile 
*source_file, const char *file_
        else
                source_file->lang = tm_ctags_get_named_lang(name);
 
-       source_file->is_c_source = FALSE;
+       source_file->trust_file_scope = TRUE;
 
+       /* ctags sets "isFileScope" for all C/C++ files without a known header
+        * extension, but we don't want to use it for files with a less 
conventional
+        * extension, not to exclude symbols we shouldn't */
        if (source_file->lang == TM_PARSER_C || source_file->lang == 
TM_PARSER_CPP)
        {
-               const gchar **ext;
-               const gchar *common_src_exts[] =
-                       {".c", ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++", 
".CPP", ".CXX", NULL};
+               const gchar *ext = strrchr(source_file->short_name, '.');
 
-               for (ext = common_src_exts; *ext; ext++)
+               source_file->trust_file_scope = FALSE;
+               if (ext)
                {
-                       if (g_str_has_suffix(source_file->short_name, *ext))
+                       const gchar *common_src_exts[] =
+                               {"c", "C", "cc", "cp", "cpp", "cxx", "c++", 
"CPP", "CXX"};
+
+                       for (guint i = 0; i < G_N_ELEMENTS(common_src_exts); 
i++)
                        {
-                               source_file->is_c_source = TRUE;
-                               break;
+                               if (strcmp(ext + 1, common_src_exts[i]) == 0)
+                               {
+                                       source_file->trust_file_scope = TRUE;
+                                       break;
+                               }
                        }
                }
        }
diff --git a/src/tagmanager/tm_source_file.h b/src/tagmanager/tm_source_file.h
index f3ca0cbc8..342d1259c 100644
--- a/src/tagmanager/tm_source_file.h
+++ b/src/tagmanager/tm_source_file.h
@@ -36,7 +36,7 @@ typedef struct TMSourceFile
        char *short_name; /**< Just the name of the file (without the path) */
        GPtrArray *tags_array; /**< Sorted tag array obtained by parsing the 
object. @elementtype{TMTag} */
        /* Flag indicating whether the file is a C/C++ source (i.e. not a 
header) based on its extension */
-       gboolean is_c_source;
+       gboolean trust_file_scope;
 } TMSourceFile;
 
 GType tm_source_file_get_type(void);
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3490#issuecomment-1541830319
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3490/[email protected]>

Reply via email to