Skip to content

Commit 7568d0b

Browse files
authored
fix(36102): fix extra new line in Organize Imports
Organize Imports was inserting extra newline. Fixes microsoft#36102
1 parent 2c16ee3 commit 7568d0b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/services/textChanges.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ namespace ts.textChanges {
889889
: format(change.node);
890890
// strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line
891891
const noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, "");
892-
return (options.prefix || "") + noIndent + (options.suffix || "");
892+
return (options.prefix || "") + noIndent + (noIndent.endsWith(options.suffix) ? "" : (options.suffix || ""));
893893
}
894894

895895
function getFormatCodeSettingsForWriting({ options }: formatting.FormatContext, sourceFile: SourceFile): FormatCodeSettings {

0 commit comments

Comments
 (0)