-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Conversation
* Pressing the TAB key on an empty line no longer inserts an additional tab. * Fixed problem that occasionally added an additional space character when typing a tab. * Disable built-in "electric chars" feature and replace with a less heavy-handed version. The new version does the following: * Only runs when closing braces are typed: "]", "}", or ")" * Only runs if the line is all whitespace (except the closing brace) This should eliminate the majority of the odd and unpredictable auto-indent behaviors.
}, | ||
onKeyEvent: function (instance, event) { | ||
if (event.type === "keypress") { | ||
var keyStr = String.fromCharCode(event.keyCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeMirror does this:
var ch = String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode);
I'm assuming this is to deal with browsers that handle keyCode/charCode differently. Should we do the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I had no idea how much of a mess JavaScript keyboard handling was until I read this page:
http://unixpapa.com/js/key.html
Luckily, for us, using keypress and checking for ASCII characters is easy:
http://stackoverflow.com/questions/1444477/keycode-and-charcode
Code updated.
Done with first review. |
Just tested this and it isn't working for me. If I'm in a blank JS file and I type: function foo() {
blah(); then hit Return after |
It looks like the problem is the "smart" argument--if I remove it, it does the right thing. So it must not be the case that passing "smart" is the same as passing nothing. |
Passing 'smart' wasn't so smart after all... removed. |
@njx
This should eliminate the majority of the odd and unpredictable auto-indent behaviors.
This fixes issues #155 and #193.