SublimeText / CoffeeScript

Syntax highlighting and checking, commands, shortcuts, snippets, watched compilation and more.
440 stars 64 forks source link

Can't insert `}` because of toggle_parens #177

Closed adriangoransson closed 10 years ago

adriangoransson commented 10 years ago

Please move the toggle_parens key binding away from the end of the number row. Or give some visual indication in the UI (status bar perhaps) that something has happened. On my Swedish QWERTY board it overrides } and I spent longer than I care to admit wondering what was wrong with my keyboard.

axelander commented 10 years ago

I had the same issue, is there a way to override this mapping?

himynameisjonas commented 10 years ago

Did a quick and dirty workaround, add { "keys": ["alt+shift+9"], "command": "insert_snippet", "args": {"contents": "}"}} to your Keybindings settings

axelander commented 10 years ago

Great, thanks! :smile:

atombender commented 10 years ago

+1. Very annoying bug, had to disable packages at random to find the culprit.

The workaround is not a complete fix, unfortunately. ST intelligently ignores the end brace when you're already before an automatically inserted one. For example, type "{" (which automatically inserts an ending "}"), "}" and you'll end up with "{}". With the workaround, you'll end up with "{}}".

ringvold commented 10 years ago

:+1:
Had the same problems with my Norwegian keyboard. Thanks for workaround!

denkristoffer commented 10 years ago

@atombender Next time you can use sublime.log_commands(True) in the console to easily find the culprit :wink:

atombender commented 10 years ago

That's fantastic. Thanks!

danjessen commented 10 years ago

I was lucky it's called better coffescript ... it was the first plugin i looked at.

markalfred commented 10 years ago

Sublime has intelligent default keybinds attached to "}". You could attach them to "alt+shift+9" in your user-defined keybinds to override the toggle_parens one, and revert back to the exact behavior you're used to...

{ "keys": ["alt+shift+9"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true }
    ]
},

That said, my apologies for overriding your keys. I tried to tie the toggle_parens command to some key combination that (a) made sense and (b) was unused, but I didn't consider the layout of Swedish/Norwegian keyboards.

This speaks to a larger issue with the plugin, though (see #147). Alt+Shift as the prefix for Better Coffeescript's keybinds has the tendency to step on the toes of various things. For that reason, it's more typical that keybinds are tied to Ctrl/Super. The problem, though, is that there are only so many combinations out there, and everything steps on some toes eventually.

That said, I'm going to add a status message, "Better Coffeescript - unable to toggle parens", when this occurs (and hopefully including that in this comment will lead people to this issue / workaround).

Again, sorry for the inconvenience.

danjessen commented 10 years ago

you are excused, no one ever thinks of Swedish/Norwegian/Danish keyboards

frans-k commented 10 years ago

For future reference, this post from the Sublime forums helped me with this, I simply removed the keybinding from the file using the PackageResourceViewer package.

http://www.sublimetext.com/forum/viewtopic.php?f=3&t=13303

You can try overriding the package file to remove the keybinding you want. For the sake of simplicity, you can use PackageResourceViewer. Simply open Default/Default (your platform).sublime-keymap. Then remove the entry you want and save. It will create the file in the correct location for the "override" behavior.

cristobal commented 10 years ago

Is there actually any need for this keybinding? The shift+8 already does the same on OS X at least if you wrap around your selection around the function arguments?

Otherwise i would recommend using either:

Who uses these symbols anyways?

EmilStenstrom commented 10 years ago

Another vote for fixing this bug asap.

+1