Hari Kumar wrote:
> Vim uses cindent for JS files which works in general nicely. There are
> a few cases where this does not work correctly. F.e.
>
> var a = {
> b: 1,
> c: "hello"
> }
>
> cindent would align b: 1 to col 0 and indent c: "hello" by shiftwidth.
> This is because of how it treats labels in C. The attached fix avoids
> this by using another 'cindentoption' value 'J' so that such lines
> could be treated differently if the file is a JS file. This also sets
> the 'j' option used by Java files in order to handle anonymous
> functions in JS. Further it changes how a 'case' label is determined,
> to suit JS also.
>
> I've tested this fix with JS & C source code and it seems working for me.
>
> Review is appreciated,
Good to see this patch.
Since you know about this stuff, can you become the maintainer of the
javascript indent plugin? If so then please update the header of the
file.
Instead of changing all calls to cin_iscase(), it's easier to rename
cin_iscase() to cin_iscase_js(), add the extra argument, and create a
new cin_iscase() that calls cin_iscase_js(arg, FALSE).
--
>From "know your smileys":
O:-) Saint
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php