Skip to content

Commit

Permalink
Revert over-eager bailout when trailing whitespace (microsoft#28848)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandersn authored Dec 4, 2018
1 parent c85460b commit ee987a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/services/formatting/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1106,10 +1106,7 @@ namespace ts.formatting {
* Trimming will be done for lines after the previous range
*/
function trimTrailingWhitespacesForRemainingRange() {
if (!previousRange) {
return;
}
const startPosition = previousRange.end;
const startPosition = previousRange ? previousRange.end : originalRange.pos;

const startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line;
const endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line;
Expand Down
14 changes: 14 additions & 0 deletions tests/cases/fourslash/formatAfterWhitespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />
////function foo()
////{
//// var bar;
//// /*1*/
////}
goTo.marker('1')
edit.insertLine("");
verify.currentFileContentIs(`function foo()
{
var bar;
}`);

0 comments on commit ee987a2

Please sign in to comment.