Skip to content

Commit cf0e2c5

Browse files
committed
Generate extra newline for import if none are present
1 parent 3be9702 commit cf0e2c5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

server/src/main/kotlin/org/javacs/kt/completion/Completions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ private fun indexCompletionItems(parsedFile: KtFile, index: SymbolIndex, partial
103103
}
104104
detail = "(import from ${it.fqName.parent()})"
105105
val pos = findImportInsertionPosition(parsedFile, it.fqName)
106-
additionalTextEdits = listOf(TextEdit(Range(pos, pos), "\nimport ${it.fqName}")) // TODO: CRLF?
106+
val prefix = if (importedNames.isEmpty()) "\n\n" else "\n"
107+
additionalTextEdits = listOf(TextEdit(Range(pos, pos), "${prefix}import ${it.fqName}")) // TODO: CRLF?
107108
} }
108109
}
109110

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.javacs.kt.progress
2+
3+
interface Progress {
4+
fun update(percent: Int): Unit
5+
}

0 commit comments

Comments
 (0)