daniel-trinh/scalariform

format region

fommil opened this issue · 2 comments

It is quite common to be editing in a codebase, that is not using scalariform, and to want to only reformat the lines of code that you've touched (thereby avoiding merge hell with other feature branches and PRs).

In particular I'd like to be able to do this via the ENSIME programmatic call to scalariform, and I can imagine others wanting the same in scala-ide.

scala-ide already supports formatting of regions but it is done by filtering out all changes that are not part of the unselected region: https://github.com/scala-ide/scala-ide/blob/4.3.0-vfinal/org.scala-ide.sdt.core/src/org/scalaide/core/internal/formatter/ScalaFormattingStrategy.scala#L36-L47

Not easy to implement on scalariform side, since it doesn't know about the region that is selected or the content that changed. But could be done by specifying a start and end offset and filtering out everything that is not inside.

This issue was moved to scala-ide#169