vim-erlang / vim-erlang-runtime

Erlang indentation and syntax for Vim
https://vim-erlang.github.io
101 stars 29 forks source link

Fun call in argument list causes incorrect indentation for later arguments #14

Closed fishcakez closed 11 years ago

fishcakez commented 11 years ago

Example:

eval(Fun, Arg) ->
    handle_result(Fun(Arg),
                      true).
hcs42 commented 11 years ago

Thanks, I can reproduce it, I will investigate it.

fishcakez commented 11 years ago

Also when used in a case:

eval(Fun, Arg) ->
    case handle_result(Fun(Arg)) of
        true ->
            true
                       end.
hcs42 commented 11 years ago

This is indeed a bug in indent.erl.

The bug is caused by the fact that I use == to check whether the current token is fun – but it turns out, if the 'ignorecase' option is turned on, == is case insensitive, i.e. "fun" == "Fun" is true, so indent.erl believes that Fun(Arg) is the beginning of an anonymous function definition. The solution is to use the ==# operator which is always case sensitive.

We have a similar problem with the searchpair function – here the solution is to add \C to the pattern (which means "be case sensitive").