-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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/C++ namespace
incorrect indentation
#6235
Comments
@archseer I don't think your commit really solves this issue. The problem is that some people indent the body of namespaces while others don't (mainly since often the majority of a source file is just the body of some namespace). In my experience, the 2nd style is more common (and nvim-treesitter uses it as well), but we should try to support both. The current indentation system cannot really handle this. It's especially bad in this case, since it causes the indentation in basically the entire file to be off by 1 if one uses a style different from the indent query. To really address the issue, the indentation system needs to be more resilient with respect to global differences in indentation. One possibility would be to always compute the tree-sitter indentation for the newly inserted line as well as for the line above. The difference can then be added to the actual indentation of the line above to get the indentation of the new line. This would make the indentation queries "self-correct" in some sence, since any incorrect style that affects both lines will just cancel out. Implementing something like that would also make it a lot easier to write new indent queries, since they will be usable even if they're not yet complete. Right now, having no treesitter indent queries is usually a lot better than having a bad/incomplete one. |
I agree with @Triton171. It wasn't obvious where the issue was coming from after upgrading to 23.03. |
This comment was marked as duplicate.
This comment was marked as duplicate.
I've had a similar issue, but with helix giving me too many indents rather than too few. Language-specific, but would it be feasible to use |
We don't accept any language specific code into core si that's not an option |
Summary
When I define a namespace, the indentation doesn't behave as expected, instead behaving as a top level statement.
VSCode
vs.mov
Helix
hx.mov
Reproduction Steps
I tried this:
hx main.cpp
I expected this to happen:
Correct indentation.
Instead, this happened:
No indentation.
Helix log
~/.cache/helix/helix.log
Platform
macOS
Terminal Emulator
alacritty 0.11.0 (8dbaa0b)
Helix Version
helix 22.12 (ce1fb9e)
The text was updated successfully, but these errors were encountered: