colhountech / js2-mode

Automatically exported from code.google.com/p/js2-mode
0 stars 0 forks source link

Auto indenting shouldn't change indentation after I've fixed it with tab #81

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Type this:
var a = {
  foo: 1
}
2. With the point at the end of the second line, type TAB then a comma 

What is the expected output? What do you see instead?
Expected:
It should stay at the indentation level you moved it to with TAB:
var a = {
          foo: 1,
}

Actual:
It gets re-indented to the original position:
var a = {
  foo: 1,
}

What version of the product are you using? On what operating system?
20080521
Emacs.app 23.0.0 Mac OS X 10.5.3

Please provide any additional information below.

Original issue reported on code.google.com by rib...@gmail.com on 20 Jun 2008 at 4:01

GoogleCodeExporter commented 8 years ago
Hi there,

Quite the same here, but it will only occur when I've an hashmap passed as a
parameter to an function/constructor.

I believe the bug starts manifest itself when you type :

1.
new Class({

})

Now inserting a semi-colon where suggested by the parser will produce 

2.
new Class({

                      });

After fixing that by pressing tab, I'll start typing inside the hashmap and tab 
again
before the property name : 

3.
new Class({
   'first'
});

Now I soon I type the colon an additional indentation is added :

4.
new Class({
         'first':
});

I assume this level of indentation is good enough (I personally like it), but 
when
I'll assign the return value of this instance to a variable, another level of
indentation is added (just after typing the colon character again) :

4.
new Class({
         'first': function() {
          //Code here
          }
});

5.
var class = new Class({
         'first': function() {
          //Code here
          }
});

6.
var class = new Class({
         'first': function() {
          //Code here
          },
         'second'
});

7.
var class = new Class({
         'first': function() {
          //Code here
          },
                  'second':
});

Best regards
Samori

Original comment by SamoriGo...@gmail.com on 28 Jun 2008 at 9:02

GoogleCodeExporter commented 8 years ago
For me this crops up passing anonymous functions as parameters. Type (! being 
point):

foo(function() !

Now hit {. You get:

foo(function() {
      !
    }

This is an acceptable indentation decision, but I'd prefer a different style. 
So I TAB:

foo(function() {
  !
    }

Now enter a statement. Any character that induces electric indentation, e.g. ( 
or ;,
will indent the line back to where it was before I TABbed.

-David

Original comment by dmho...@gmail.com on 15 Jul 2008 at 3:32