Skip to content

Commit e5c241f

Browse files
committed
add missing version/languageId to didOpen
1 parent 60a5f37 commit e5c241f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/textdocument/TextDocumentServiceHandler.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class TextDocumentServiceHandler(
105105
DidOpenTextDocumentParams().apply {
106106
textDocument = TextDocumentItem().apply {
107107
this.uri = uri
108+
languageId = file.fileType.name.lowercase()
109+
version = file.modificationStamp.toInt()
108110
text = file.inputStream.readAllBytes().decodeToString()
109111
}
110112
}

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/workspace/WorkspaceServiceHandler.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import org.eclipse.lsp4j.CreateFilesParams
2020
import org.eclipse.lsp4j.DeleteFilesParams
2121
import org.eclipse.lsp4j.DidChangeWatchedFilesParams
2222
import org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams
23+
import org.eclipse.lsp4j.DidCloseTextDocumentParams
24+
import org.eclipse.lsp4j.DidOpenTextDocumentParams
25+
import org.eclipse.lsp4j.TextDocumentIdentifier
26+
import org.eclipse.lsp4j.TextDocumentItem
2327
import org.eclipse.lsp4j.FileChangeType
2428
import org.eclipse.lsp4j.FileCreate
2529
import org.eclipse.lsp4j.FileDelete
@@ -135,6 +139,31 @@ class WorkspaceServiceHandler(
135139
val oldUri = toUriString(parentFile)?.let { parentUri -> "$parentUri/$oldFileName" }
136140
val newUri = toUriString(renamedFile)
137141

142+
// First close the old document
143+
oldUri?.let { uri ->
144+
languageServer.textDocumentService.didClose(
145+
DidCloseTextDocumentParams().apply {
146+
textDocument = TextDocumentIdentifier().apply {
147+
this.uri = uri
148+
}
149+
}
150+
)
151+
}
152+
153+
// Then open the new document
154+
newUri?.let { uri ->
155+
languageServer.textDocumentService.didOpen(
156+
DidOpenTextDocumentParams().apply {
157+
textDocument = TextDocumentItem().apply {
158+
this.uri = uri
159+
languageId = renamedFile.fileType.name.lowercase()
160+
version = renamedFile.modificationStamp.toInt()
161+
text = renamedFile.inputStream.readAllBytes().decodeToString()
162+
}
163+
}
164+
)
165+
}
166+
138167
FileRename().apply {
139168
this.oldUri = oldUri
140169
this.newUri = newUri

0 commit comments

Comments
 (0)