[closebrackets] in comment, addon closes parens but not quotes
See original GitHub issuehttps://codemirror.net/demo/closebrackets.html
Repro:
- add
//
to a line - type
(
after it - type
'
after it
Expected: Either they should both be completed with the closing pair (preferable), or neither of them should be.
Actual:
A )
is automatically inserted, but a '
is not
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
[closebrackets] in comment, addon closes parens but not quotes
I'm not sure I understand why tokenization is relevant here. Is tokenization (or other non-local info) used for closing other types of brackets?...
Read more >Automatic closing brackets for Vim - Stack Overflow
Is there any WORKING plugin for Vim 7.4 that would automatically close brackets ('{}', '[]', '()') and maybe insert some carriage returns (for...
Read more >Which auto-closing plugin do you use? : r/neovim - Reddit
The only issue I've had is that on very rare occasions the editor slows down due to an unclosed closing parenthesis. But it...
Read more >How disable auto closing of brackets, quotes, curly braces etc ...
Hello everybody, I work at an webdev company and we recently switched from eclipse to IntelliJ. I really like IntelliJ over eclipse as......
Read more >Release History - CodeMirror
Fix issue that broke binding the macOS Command key. comment addon: Keep selection in ... closebrackets addon: Improve behavior when closing triple quotes....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That heuristic seems to catch most cases—it seems the code was already doing all of that except for the check for a word char before the cursor. Attached patch adds this, replacing the string token heuristic. This will lead to suboptimal behavior when a string ends in a non-word character and is, for some reason, not closed by the automatically inserted matching quote from the opening quote, but it’s much simpler.
Does this work for you?
Quote-closing in general does not work in contexts that don’t tokenize quoted strings, because it is impossible to generally decide whether a quote opens or closes a string. This is intentional—even with a bunch of heuristics (recognizing comment or nested string context, counting quotes, etc) this’d be very error-prone, and I don’t want to go there.