Selective bracket insertion/skipping for quotes #1065

merged 8 commits into from Nov 12, 2012


None yet
3 participants

lennartcl commented Oct 24, 2012

As a minor followup on #1055, this adds the same selective behavior to quotes and other minor fixes.



nightwing commented Oct 24, 2012

i noticed this is more strict than sublime
sublime adds closing bracket if next character is a space
is this strictness intentional?


nightwing commented Oct 25, 2012

I think this is still too restrictive, even|.bar isn't converted to|).bar.
Textmate only checks for next letter being word_char which is much simpler and predictable.

Otherwise this looks good, so if you really want to keep current behavior, feel free to merge this.


lennartcl commented Nov 2, 2012

Okay, it should definitely insert before the ., so consider that a bug :). The current implementation is based mostly on the Eclipse and Spoofax behavior, and their tokenization works a bit differently. Anyway, I relaxed it a bit more.

There's still one scenario that bothers me a bit, and I'm not sure what to do about it. It's what happens if you have code like


and want to put a try/catch or if or something around it. You'll get something like

try {}

which is quite annoying :( What Eclipse does is show try { and only insert the closing } if you hit enter again. Could that work for us with JavaScript? The only thing is that you wouldn't get a closing bracket when you want to write a function closure on one line :/ But I'd rather miss a closing bracket that get one too many. Any suggestions?


mostafaeweda commented Nov 7, 2012

Yes, I agree with you
I prefer the editor not typing stuff for me that I'll have to delete rather than I add the closing bracket myself


lennartcl commented Nov 12, 2012

@mostafaeweda Thanks for your feedback!

Alright, I updated the implementation to handle that scenario: curly brackets are now no longer inserted until you press enter:

try {

plus enter


try {


Things are getting a bit more complicated as we go along, but it basically follows the spec from Eclipse and also does bracket skipping the same way as TextMate does it.

nightwing added a commit that referenced this pull request Nov 12, 2012

Merge pull request #1065 from ajaxorg/selective-bracket-insertion
Selective bracket insertion/skipping for quotes

@nightwing nightwing merged commit bd41009 into master Nov 12, 2012

1 check was pending

default The Travis build is in progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment