-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Vim: Typescript/tsx anybrackets selection is wrong #25146
Comments
The cursor at the start of the selection for multi-line {} was actually on purpose to match nvim. I think any visual bracket operations have the cursor at the start, paragraphs have the cursor at the start of the last line, and words and other motions/objects have it at the end in nvim(treesitter). I could be missing some, thats just from what i tried. |
Ah, right. I really don't mind it; I was just a little surprised that it was different from all the other cases. That said: I've never known which to expect, so I really don't mind 😅 If it's intentional, we can ignore that one. |
Yeah i agree its weird haha, i have no preference i was just using nvim as a reference so i tried to match the functionality as much as possible. If it's something nobody likes/has a preference maybe we can have it always move to the end, so it is more predictable? 🤷♂️ |
To be honest, I think (heavy emphasis on "think") it makes more sense to me to always have the cursor at the start of the selection, but Vim puts it at the end. I'd assume that's why Zed does the same thing. I don't have any strong preferences. I had to go check with vim to even make sure that was how it did it. Which probably indicates that I don't use it enough to voice a real opinion 😅 So ... yeah 🤷🏼 For consistency, it might be nice, but if no one complains, then it might not be worth spending time on 💁🏼 |
Summary
In a JSX/TSX component with multiple levels of brackets, anybrackets selects wrong and/or mismatching sets of delimiters. Using the actual brackets in the command (e.g.
vi(
) works as expected.Steps to trigger the problem:
vib
orvab
and notice it does very weird thingsActual Behavior:
From
void
:vib
:vab
:From
{
vib
:vab
(this one is actually correct):Expected Behavior:
From
void
vib
(same asvi{
):vab
(same asva{
):From
{
vib
:vab
:Thoughts/observations
It looks as if the
=>
construct in TS might be confused with a closing angle bracket, so that when going from void, it thinks the delimiters are the start of the component and the fat arrow:=>
.There appears to be a second bug here that I think was introduced recently with the fix for not selecting whitespace in a multi-line {} (this is relevant for the
vi{
option). For all othervi
selections, the cursor ends up at the end of the selection, but for the multilinevi{
, it ends up at the start of the selection.Zed Version and System Specs
Zed: v0.173.11 (Zed)
OS: macOS 14.6.1
Memory: 16 GiB
Architecture: aarch64
The text was updated successfully, but these errors were encountered: