Skip to content

Commit 23935fa

Browse files
committed
Fix formatOnSave by try reading the content from memory first
1 parent 1a8da75 commit 23935fa

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ class KotlinTextDocumentService(
6161
get() = uri.endsWith(".kts")
6262

6363
private val TextDocumentIdentifier.content: String
64-
get() = uriContentProvider.contentOf(parseURI(uri))
64+
get() {
65+
val uri = parseURI(uri)
66+
return sf.contentOfTracked(uri) ?: uriContentProvider.contentOf(uri)
67+
}
6568

6669
fun connect(client: LanguageClient) {
6770
this.client = client

server/src/main/kotlin/org/javacs/kt/SourceFiles.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ class SourceFiles(
113113
}
114114
}
115115

116+
fun contentOfTracked(uri: URI):String? {
117+
return files[uri]?.content
118+
}
119+
116120
fun createdOnDisk(uri: URI) {
117121
changedOnDisk(uri)
118122
}

0 commit comments

Comments
 (0)