
js2-mode - issue #93
Extra indentation in object literal of lines with slot name IN
What steps will reproduce the problem? 1. Use IN as a field name in a literal object. E.g.
var foo = { X : 10, IN : 20, OUT : 30, Y : 40 };
Indent lines with <TAB> (with bounce-mode indentation turned off)
Note that the IN line gets indented extra.
What is the expected output? What do you see instead?
I see this:
var foo = { X : 10, IN : 20, OUT : 30, Y : 40 };
I expect this:
var foo = { X : 10, IN : 20, OUT : 30, Y : 40 };
What version of the product are you using? On what operating system?
js2-20080616a.el on GNU Emacs 22.0.99.1 (powerpc-apple-darwin8.9.0, Carbon Version 1.6.0) of 2007-05-06 on beagle
Please provide any additional information below.
I'm guessing that may have something to do with 'in' being a keyword. But unless I'm confused Javascript is case sensitive so 'IN' should not be treated specially. On the other hand, a quick look through the source didn't show up any obvious places where case is ignored or smashed so that guess may be totally wrong. And if I change the IN to say FOR or WHILE it still indents correctly, so it's not all upcased keywords that are a prooblem.
Comment #1
Posted on Nov 7, 2008 by Massive OxHere's a patch that seems to fix the problem:
--- /Users/peter/Desktop/js2-20080616a.el 2008-11-06 08:11:37.000000000 -0800 +++ js2.el 2008-11-06 23:09:19.000000000 -0800 @@ -9985,11 +9985,12 @@ "Return non-nil if text after point is an operator (that is not a comma)." (save-match-data - (and (looking-at js-indent-operator-re) - (or (not (looking-at ":")) - (save-excursion - (and (js-re-search-backward "[?:{]\|\" nil t) - (looking-at "?"))))))) + (let ((case-fold-search nil)) + (and (looking-at js-indent-operator-re) + (or (not (looking-at ":")) + (save-excursion + (and (js-re-search-backward "[?:{]\|\" nil t) + (looking-at "?"))))))))
(defun js-continued-expression-p () "Returns non-nil if the current line continues an expression."
Status: New