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

Adding on closing ] is eaten when the next character is a ] #6528

Open
Ducasse opened this issue Jun 9, 2020 · 3 comments
Open

Adding on closing ] is eaten when the next character is a ] #6528

Ducasse opened this issue Jun 9, 2020 · 3 comments

Comments

@Ducasse
Copy link
Member

Ducasse commented Jun 9, 2020

Type

[ :x | [ 2  ]
  • place the cursor just before the last ]
  • type ]
  • the new character ] does not appear so you have to type it again.
@olekscode
Copy link
Member

This is a common logic for many editors and IDEs.
For example, if you open SublimeText and type (1 + 2), then you move your cursor just before the last ) and type ) it will simply move the cursor one character to the right and insert nothing.

This happens because when you type the opening (, [, {, ', ", the closing one is inserted automatically and the cursor is placed between them. Many people still try to close them manually, so to save time and not produce duplicates, the thing that you described happens.

I don't think this feature should be removed.
It seems to make a lot of sense.

@Ducasse
Copy link
Member Author

Ducasse commented Jul 1, 2020

But why when I add a character then it does not appear.
To me this is a bug and not a feature.

I do not get why typing twice that character would be great and desired.
What you describe can work for one level

[:x | caret here ]

But I'm not talking about this but about the fact that there is still a block to close and I do not see
why closing the block should be only possible outside the inner block.

The logic of the closing parenthesis should take into account that several parentheses were open!

@pavel-krivanek
Copy link
Collaborator

So, while this "feature" drives me crazy a lot, I have some arguments against Olek's explanation:

  • write first ] then go before it and write ] - you have a pair which is not autocompleted and it anyway eats the next ] if you write it
  • for character pairs which add extra space (by default {} and []), you need to move your cursor further because the the space is not automatically eaten as the parentheses are - but then, if you move the cursor behind the space and then you write parentheses which are eaten.
Here, the | character is a cursor
|       - type [
[ | ]   - type space
[  | ]  - type backspace to revert
[ | ]   - press right arrow
[  |]   - press ]
[  ]|   - huh???

Simply, this behavior is broken and - if not removed completely - it should be a preference which is turned off by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants