Use the line splitting solution from the original source for splits outside of the formatting range
Summary:
Currently, range formatting simply prints a substring of the full formatted source. This causes problems when the original source represents a line-breaking solution different from the one hackfmt would produce. For example, consider as-you-type formatting on this source:
```
Vec\map($foo, $x ==> {
bar($x);
baz($x);
});
```
If you try to format at the semicolon after the call to `bar`, you'll get incorrect indentation:
```
Vec\map($foo, $x ==> {
bar($x);
baz($x);
});
```
The reason is that hackfmt actually wants to format the whole code block like this:
```
Vec\map(
$foo,
$x ==> {
bar($x);
baz($x);
},
);
```
But the result of hackfmt is only the changed range, which includes this extra indent.
This diff binds all splits outside of the formatting range to the solution in the original source, constraining hackfmt to change line breaks only within the formatting range. This fixes the indentation problem in this example.
Reviewed By: arxanas
Differential Revision:
D5853970
fbshipit-source-id:
575ecd9b5286f4294ecc8e6328ad5bef6321f5ee