rstudio/rstudio — pull request #143 by kevinushey (2014-07-24 07:16:09+00:00)
Title: Fix some bugs in the outdenting for R code in non-R modes

NOTE: Definitely leave this one for later as it touches the code indentation and may have broken things I haven't been able to test yet...

This fix has a few components:

1. In 'r_matching_brace_outdent', the autoOutdent method attempted to
access the code model through 'this'. Unfortunately, 'codeModel' is not
actually available through 'this' since the reference is bound before it
ever gets to know about the code model. A simple fix here is to add
the code model to those function signature. (from what I see, before, an
exception would be thrown but silently swallowed up by its caller)

2. The 'checkOutdent' and 'autoOutdent' were not matching the signatures
correctly. This is understandable since the signature in our
RMatchingBraceOutdent diverged from that of Ace's MatchingBraceOutdent.
This is now fixed.

3. Although I don't really know why, the way that the
RMatchingBraceOutdent was mixed in to 'r.js' didn't seem to work (?), so
I followed the pattern in the other files.

Ironically, the combination of the two bugs above made R code
indentation for closing '}' work fine, but broke it in other modes.

Ultimately, this fixes a bug where reindenting R code within an .Rmd,
.Rnw, or .cpp file would produce formatted e.g. like:

for (i in 1:10) {

}

ie, the closing brace offset is now properly aligned in these files. It
(should) preserve indentation behaviour in vanilla R modes.