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
Better behavior of the autoClosingBrackets-Feature for quotation marks #7092
Comments
This issue has impacted me as well (version 1.4.0 Win8). I was giving a demo and using VS Code "as a very helpful editor" when I made the following mistake in some html: onclick="alert("Hi");" When I highlighted the " in front of Hi and typed ' I got ' " ' (Like the OP, spaces added for clarity), which I then had to delete. Ok, but things get wackier... The cursor is placed after the ", so I hit backspace twice to delete it and the preceding '. But this auto-deletes the trailing ' after the cursor (try it out to see what I mean.) So I have to type the single quote all over again. That gets us to this point: onclick="alert('Hi");" OK, well, obviously if I select the " after Hi and type ' I'll get the same behavior, so let's try something different... If I delete the " and type ' after the Hi then I get a pair of single quotes: onclick="alert('Hi'');" That's not what I wanted, so I hit backspace, but that deletes the pair of 's, which is also not what I wanted... So finally, I type ' again, which gives me ' ' and I can hit the Delete key (not backspace) and then I've finally corrected this simple typo. This description might be hard to follow but if you start out with an html file, create my original typo in an html tag and then try different ways of fixing it, you'll see what I mean. Finally, I've read about turning off autoClosingBrackets, but I like the auto closing of the brackets OK, just not of the quotes. [Side suggestion - Alphabetize the contents of the default settings file...? At least within a group like editor.*?] |
I've seen a similar issue when, for whatever reason, I end up with mismatched quotes. If a line has quotes at the start, but the end is missing a quote, I go to the end of the line and type I get the same issue with brackets, though that's not nearly so bad. |
I have a lot of empathy for the folks who have posted and upvoted in this thread. But I'm not sure it's possible to get this exactly right in all cases. After all, there are certainly plenty of times when a programmer might legitimately want the existing behavior (e.g. to convert a naked single-quote character into a double-quoted string of length one whose content happens to be the original single-quote character). Better detection of intention (assuming that's even possible) might come down to significantly more sophisticated language parsing, and that might be difficult to implement and could easily add a lot of overhead (read: make the editor feel more sluggish). So a better angle of attack might be to suss out what different kinds of behavior would be desirable and move some of those behaviors to other settings or other keymappable actions. Maybe converting existing brackets to different brackets could be its own thing, for example, separate from adding new surrounding brackets. Potentially another key combo to learn, but less chance the editor will do something against the user's wishes. |
just please leave me the option to disable ALL AUTO closing of every kind. I have never liked it in any editor. If the editor shows a closing bracket I worry I've typed it early on accident. If it tries to auto wrap my selection, I'm confused about what I typed. I don't care how advanced and fancy this feature gets, just leave me a way out. please. |
I played with latest Code Insiders, and selecting a BTW, we introduced |
I am very glad that brackets and quotes can now be autoclosed separately. I've got autoclosing disabled for brackets and enabled for quotes. So far, so good. This seems to have the happy side-effect that the behavior of prefixed strings in Python (like I actually would use autoclosing brackets too if not for their interaction with autoindent, as I described in #34861. That is a show-stopper for me. I have an open question for everyone who uses autoclosing brackets: Once you've created some code like the following (pretend that the pipe character is the cursor):
After you're done typing the contents that go between the parens, how do you get past that closing paren? Do you use arrow keys? Do you use the mouse? I am genuinely curious about this, because I think it is the only thing stopping me from turning autoclose on for brackets. |
As discussed in issue #327, the
autoClosingBrackets
option has some edge cases where it does not speed up typing but actually increases the work necessary. One of these cases is when I try to replace quotation marks as start and end character of strings.Steps to Reproduce:
The same issue occurs when I use the grave accent to replace double quotation marks. It would be great if VS Code could detect the intention and overwrite the selected character or replace the start and end chartacter of the string (e.g. 'Hello World' becomes "Hello World" or
Hello World
based on the new character).The text was updated successfully, but these errors were encountered: