From 58fdd011df74f226f1909a2155896e43fc5c2042 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 31 May 2016 14:08:48 -0700 Subject: [PATCH] avoid eating all preceding empty lines --- src/services/formatting/formatting.ts | 2 +- tests/cases/fourslash/{ => server}/formatOnEnter.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/cases/fourslash/{ => server}/formatOnEnter.ts (100%) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 7127eb9800..ef8fddcfb3 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -84,7 +84,7 @@ namespace ts.formatting { // if the character at the end of the span is a line break, we shouldn't include it, because it indicates we don't want to // touch the current line at all. Also, on some OSes the line break consists of two characters (\r\n), we should test if the // previous character before the end of format span is line break character as well. - while (isLineBreak(sourceFile.text.charCodeAt(endOfFormatSpan))) { + if (isLineBreak(sourceFile.text.charCodeAt(endOfFormatSpan))) { endOfFormatSpan--; } const span = { diff --git a/tests/cases/fourslash/formatOnEnter.ts b/tests/cases/fourslash/server/formatOnEnter.ts similarity index 100% rename from tests/cases/fourslash/formatOnEnter.ts rename to tests/cases/fourslash/server/formatOnEnter.ts