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

Jumping to matching brace not as expected #3419

Closed
Giessen opened this issue Aug 6, 2024 · 8 comments · Fixed by #3432
Closed

Jumping to matching brace not as expected #3419

Giessen opened this issue Aug 6, 2024 · 8 comments · Fixed by #3432

Comments

@Giessen
Copy link

Giessen commented Aug 6, 2024

Description of the problem

I bind C-] to JumpToMatchingBrace. Press C-] on one of paired braces, cursor go to after the paired brace instead of its accurate position.

Steps to reproduce

  1. In ~/.config/micro/bindings.json:
    "CtrlRightSq": "JumpToMatchingBrace",
  2. Open any txt file, type: {balabala}
  3. Move to the left {, press C-]
    Expected: watch the cursor move TO } (cursor block covering }). ( for cursor style being '|', actually before } )
    Actual: the cursor move after }

NOTE: same problem to jump from } to {.

Specifications

Version: 2.0.14-dev.245
Commit hash: 2259fd1
OS: WSL2
Terminal: Zsh

Related issue:

#3308

@Andriamanitra
Copy link
Contributor

It works as expected: If you start from outside the brackets it jumps outside the corresponding bracket, and if you start from inside it jumps inside the corresponding bracket.

       outside to outside
     ┌───────────────────┐ 
. . . { b a l a b a l a } . . .
       └───────────────┘
        inside to inside

@Giessen
Copy link
Author

Giessen commented Aug 6, 2024

Thanks for the great explaination. Now I see the logic which is designed on purpose. Is there any special consideration for this design? Personally I find this way is more intuitive:
image
image
😄

@dmaluka
Copy link
Collaborator

dmaluka commented Aug 6, 2024

Please see #2876 (comment).

TL;DR this behavior was originally introduced in #1054 as a separate option (disabled by default) and later was "merged" into the default behavior.

@Giessen
Copy link
Author

Giessen commented Aug 7, 2024

Thank you very much for the info. Is there an easy fix or settings so I can disable the "closing brace to left/right of cursor"? IMHO, this causes more mental burden than otherwise and leads to hard to follow/predict results. One e.g. stated in #2876: (xyz)(xyz)

I do a test as following:

  1. initial cusror position
    image
  2. pressing key (C-]) to execute JumpToMatchingBrace
    image
  3. pressing key (C-]) again
    image
    We can see in step3, the cursor moves to next closing brace, rather than return back to original '(' as intuitively expected.
    Maybe this behaviour is useful in some situations which I have never encountered with :). But It seems to be better to have an option to toggle on/off.

@dmaluka
Copy link
Collaborator

dmaluka commented Aug 7, 2024

Is there an easy fix or settings so I can disable the "closing brace to left/right of cursor"?

There is none, but we can probably implement it.

@dmaluka
Copy link
Collaborator

dmaluka commented Aug 18, 2024

You can try with PR #3432 (with matchbraceleft option disabled).

@JoeKar
Copy link
Collaborator

JoeKar commented Aug 18, 2024

Setting matchbraceleft to false should do the trick now for the expected behavior of this issue.

@Giessen
Copy link
Author

Giessen commented Aug 20, 2024

I can confirm it works great. Thanks for the contribution.

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

Successfully merging a pull request may close this issue.

4 participants