Adding on closing ] is eaten when the next character is a ]
Type
[ :x | [ 2 ]
- place the cursor just before the last ]
- type ]
- the new character ] does not appear so you have to type it again.
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.
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!
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