Skip to content

Commit 2bc044e

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

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/services/textChanges.ts

Lines changed: 1 addition & 1 deletion
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 + (((options.suffix && noIndent.match(options.suffix+"$")) || !options.suffix) ? "" : options.suffix);
893893
}
894894

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

0 commit comments

Comments
 (0)