Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C query issue: Function after global variable is not detected #413

Open
ronandalton opened this issue Sep 22, 2024 · 0 comments
Open

C query issue: Function after global variable is not detected #413

ronandalton opened this issue Sep 22, 2024 · 0 comments
Assignees

Comments

@ronandalton
Copy link

ronandalton commented Sep 22, 2024

Language: C
AerialInfo:

Aerial Info
-----------
Filetype: c
Configured backends:
  treesitter (supported) (attached)
  lsp (supported)
  markdown (not supported) [Filetype is not markdown]
  asciidoc (not supported) [Filetype is not asciidoc]
  man (not supported) [Filetype is not man]
Show symbols: Class, Constructor, Enum, Function, Interface, Module, Method, Struct

The minimal amount of code that demonstrates the missing symbol:

01  int var = 5;
02  
03  int foo() { // undetected
04      return 0;
05  }
06  
07  int bar() {
08      return 0;
09  }

Expected symbol: Function named foo at lines 3-5

Explanation

A function following a global variable declaration doesn't appear to be detected. It appears that lines from 1-5 are detected as being part of a function named var, but var is actually just a variable on line 1 (also happens with arrays). Here is the output from get_location(true) at line 4:

{
  {
    col = 4,
    icon = "󰊕 ",
    kind = "Function",
    lnum = 1,
    name = "var"
  }
}

The C++ query file doesn't seem to have this issue when identical code is used (putting it in a .cpp file instead of a .c file). Perhaps a solution is just to use the same query file for both languages (or a stripped down version of the C++ query file)? Actually it looks you can't simply do that. I guess the parsers are different. Unfortunately I don't know enough about treesitter queries to fix this myself.

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants