tamzinblake / js3-mode

A chimeric fork of js2-mode and js-mode
GNU General Public License v3.0
181 stars 13 forks source link

Use parser for indentation #34

Closed tamzinblake closed 12 years ago

tamzinblake commented 12 years ago

The lazy regex approach has failed. Now that a reparse can be forced before indentation, both comma-first and operator-first should use the AST to determine where things should be placed based on precedence / node type.

The parser doesn't preserve the order-of-operations structure spelled out in the spec, but it should provide enough to make the relevant distinctions.

Thus, the rule for commas becomes simply, "line up with the previous sibling comma, or with the last character of the parent node" (roughly).

Comments welcome.

tamzinblake commented 12 years ago

This should fix several existing issues, simplify the fixes for previous issues, and curtail future bugs.