-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
bracket matching works incorrectly sometimes #3357
Comments
This appears to be because the bracket matching expects matching brackets to be the border of a tree sitter node, but in this case let a = Some(5); where Is this an issue/bug in tree-sitter-rust (that they should group the |
If matching brackets within a node is possible without behavior regressions, that'd be preferrable. tree-sitter-rust actually already exposes a node just for the (call_expression
function: (identifier) ; "Some"
arguments:
(arguments ; "(5)"
(integer_literal))) ; "5" So I'm not sure there's a change in tree-sitter-rust we can make to improve the situation. |
That's correct, but the problem is that in the case of match arms: |
Oh yeah in |
Also facing this issue with Zig: const std = @import("std");
const StringHashMap = std.StringHashMap;
pub fn MyStruct() type {
return struct {
const Self = @This();
map: StringHashMap,
pub fn init() Self {
return Self{
.map = StringHashMap([]const u8).init(),
};
}
}; // <-- 'mm' here
} // <-- jumps here The 2nd last |
Should this be a separate bug report? I get wrong bracket matching with the following <!-- () --> <!-- ) --> <!-- ( --> The comments may contain more content. (Makes no difference.) This is a minimal reproduction. In each instance, all matching brackets to Here is how Note that the matching bracket to |
Same issue in C++ with macros: #define TEST(A, B) ((A) + (B)) None of the parenthesis in |
I think that's a separate issue. |
I know this is not the perfect solution, but it would alleviate glaring cases like the one presented in this issue, where you are on top of the bracket: #7238 I see it more as a trade-off to improve experience to most users with minimal required work. |
this is a pretty big edge-case. ) was able to handle everything else through TS bet C preprocessor tokens are just plaintext blobs. I handled that case with a super restrictive plaintext fallback. That case could be handled with TS too by injecting c into c preprocessor nodes the way nvim does but that feels hacky... |
Summary
For example in this example, with the cursor on either one of the parentheses in
Some(thing)
, the matching one is not highlighted and hittingmm
doesn't take you to the matching one, instead it takes you to the bracket on line 6.Reproduction Steps
asciinema
I tried this:
hx
Some(thing)
mm
I expected this to happen:
The matching parenthesis is highlighted in step 3, and moved to in step 4
Instead, this happened:
Nothing is highlighted in step 3, and the bracket on line 6 is gone to in step 4
Helix log
~/.cache/helix/helix.log
Platform
Linux
Terminal Emulator
Kitty
Helix Version
22.05-376-g6b84344e
The text was updated successfully, but these errors were encountered: