Skip to content

Commit 2a30ddd

Browse files
authored
fix(amazonq): add delay between fileOpen messages (#5870)
LSP appears fragile and locks up if flooded with messages on startup
1 parent d487d47 commit 2a30ddd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.intellij.openapi.vfs.newvfs.BulkFileListener
2323
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
2424
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
2525
import kotlinx.coroutines.CoroutineScope
26+
import kotlinx.coroutines.delay
2627
import kotlinx.coroutines.launch
2728
import org.eclipse.lsp4j.DidChangeTextDocumentParams
2829
import org.eclipse.lsp4j.DidCloseTextDocumentParams
@@ -65,9 +66,12 @@ class TextDocumentServiceHandler(
6566
)
6667

6768
// open files on startup
68-
val fileEditorManager = FileEditorManager.getInstance(project)
69-
fileEditorManager.openFiles.forEach { file ->
70-
handleFileOpened(file)
69+
cs.launch {
70+
val fileEditorManager = FileEditorManager.getInstance(project)
71+
fileEditorManager.openFiles.forEach { file ->
72+
handleFileOpened(file)
73+
delay(100)
74+
}
7175
}
7276
}
7377

0 commit comments

Comments
 (0)