question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[closebrackets] in comment, addon closes parens but not quotes

See original GitHub issue

https://codemirror.net/demo/closebrackets.html

Repro:

  1. add // to a line
  2. type ( after it
  3. 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:closed
  • Created 6 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
marijnhcommented, Nov 7, 2017

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?

1reaction
marijnhcommented, Nov 1, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found