Skip to content

Commit ee987a2

Browse files
authored
Revert over-eager bailout when trailing whitespace (#28848)
1 parent c85460b commit ee987a2

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/services/formatting/formatting.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,10 +1106,7 @@ namespace ts.formatting {
11061106
* Trimming will be done for lines after the previous range
11071107
*/
11081108
function trimTrailingWhitespacesForRemainingRange() {
1109-
if (!previousRange) {
1110-
return;
1111-
}
1112-
const startPosition = previousRange.end;
1109+
const startPosition = previousRange ? previousRange.end : originalRange.pos;
11131110

11141111
const startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line;
11151112
const endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path="fourslash.ts" />
2+
////function foo()
3+
////{
4+
//// var bar;
5+
//// /*1*/
6+
////}
7+
goTo.marker('1')
8+
edit.insertLine("");
9+
verify.currentFileContentIs(`function foo()
10+
{
11+
var bar;
12+
13+
14+
}`);

0 commit comments

Comments
 (0)