When I was fixing an issue with formatting in brace completions I had to do some extra work to make sure the caret position wasn't moved off of a line because the following line would be edited
```
function f(){
function g(){
|
}
}
```
needed formatting to
```
function f(){
function g(){
|
}
}
```
but would move the caret
```
function f(){
function g(){
|}
}
```
To bring this behavior back, just remove the call to format in the OnReturn method.
I suspect we are replacing whitespace before the '}' as '\r\n' -> '\r\n ' and that is causing the caret to move to the end of the space as the caret is located before the \r\n, though in VirtualWhitespace.
```
function f(){
function g(){
|
}
}
```
needed formatting to
```
function f(){
function g(){
|
}
}
```
but would move the caret
```
function f(){
function g(){
|}
}
```
To bring this behavior back, just remove the call to format in the OnReturn method.
I suspect we are replacing whitespace before the '}' as '\r\n' -> '\r\n ' and that is causing the caret to move to the end of the space as the caret is located before the \r\n, though in VirtualWhitespace.