Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function-literal indentation #73

Open
TaylanUB opened this issue Oct 24, 2012 · 1 comment
Open

function-literal indentation #73

TaylanUB opened this issue Oct 24, 2012 · 1 comment

Comments

@TaylanUB
Copy link

It seems function-literal indentation is not properly handled in some cases. Examples include function-literals in arrays, and assignment to the result of a function call with a function-literal argument:

foo = bar(function(){
        blah
      });
foo([function(){

     }]);

Detecting each such case is probably not necessary. Can't we just look back for the regex \bfunction *(\( *[a-zA-Z$_][a-zA-Z0-9$_]*\)* *) *{ *\n * or so (emacs regex).
(I probably left out some valid identifier characters from the []. And I disregarded tabs.)

I should point out that the new js2-mode on GitHub has this issue fixed. Unfortunately it's still not the first Google hit for "js2-mode": https://github.com/mooz/js2-mode

@tamzinblake
Copy link
Owner

js2-mode's issue would be different since it has entirely different indentation code. Where possible I don't use regexes since the language is too complex (just put a regular expression literal containing slashes in that chain).

There are a number of special cases that I'd like to handle differently, but there are caveats to all of them. I think I'll put a page up on the wiki soon detailing the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants