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 scope highlight problem with newlines in if statements #766

Closed
Danielkonge opened this issue Nov 8, 2023 · 2 comments
Closed

C scope highlight problem with newlines in if statements #766

Danielkonge opened this issue Nov 8, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Danielkonge
Copy link
Contributor

Problem

Scope highlighting doesn't have the expected behavior with certain formatting styles.

This is the expected behavior:

Screenshot 2023-11-08 at 16 54 42 Screenshot 2023-11-08 at 16 57 07 Screenshot 2023-11-08 at 16 57 23

I think these are also all okay, but I am not sure about the exact scopes here:
Screenshot 2023-11-08 at 16 53 51
Screenshot 2023-11-08 at 16 54 11
Screenshot 2023-11-08 at 16 54 19
Screenshot 2023-11-08 at 16 54 33

This is wrong:
Screenshot 2023-11-08 at 16 54 25

As shown in the first few pictures, this highlighting can be fixed by changing the formatting a bit, but hopefully the code should still work correctly in this case.

Steps to reproduce

nvim --clean -u min-init.lua keeps giving errors when I run it with the minimal config file, so I don't have the minimal config, but I don't think the issue is hard to reproduce.

Make a c file with:

int main(int arg1,
         char **arg2,
         char **arg3
         )
{
  if (arg1 == 4
    && arg2 == arg3) {
    int tmp = 1;
    // comment
  } else {
    int tmp  = 2;
    // comment
  }
}

Move the cursor around different lines and look at the scope highlights.

Expected behavior

Screenshot 2023-11-08 at 16 54 25

In this picture the scope should highlight the second indentation guide to the left of the cursor.

Neovim version (nvim -v)

NVIM v0.10.0-dev-1451+g20dd9f3a2-Homebrew

@Danielkonge Danielkonge added the bug Something isn't working label Nov 8, 2023
@lukas-reineke
Copy link
Owner

Isn't this just a duplicate of #752

@Danielkonge
Copy link
Contributor Author

I didn't think it was the same problem because the indent guides looked different, but looking at it again I think that is just because of smart_cap_indent. I think you are right that this is a duplicate, so I will close this issue and make a comment in the other issue instead. I think I might have a way to solve this after current_indent is committed (I would use that the calculation loop and drawing loop are different then).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants