Skip to content

Commit 84d5031

Browse files
Merge branch 'main' into diagnostics
2 parents f182d6b + 91efe31 commit 84d5031

File tree

8 files changed

+122
-72
lines changed

8 files changed

+122
-72
lines changed

.changes/3.82.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"date" : "2025-07-03",
3+
"version" : "3.82",
4+
"entries" : [ {
5+
"type" : "bugfix",
6+
"description" : "Skip inline completion when deleting characters"
7+
} ]
8+
}

.changes/next-release/bugfix-2488e2f1-f725-4e01-b38a-8b6953cf5f18.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# _3.82_ (2025-07-03)
2+
- **(Bug Fix)** Skip inline completion when deleting characters
3+
14
# _3.81_ (2025-06-27)
25

36
# _3.80_ (2025-06-26)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# Toolkit Version
5-
toolkitVersion=3.82-SNAPSHOT
5+
toolkitVersion=3.83-SNAPSHOT
66

77
# Publish Settings
88
publishToken=

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,16 @@ fun buildUserInputCustomDependencyVersionsChatContent(message: String) = CodeTra
356356
type = CodeTransformChatMessageType.PendingAnswer,
357357
)
358358

359-
fun buildPromptTargetJDKNameChatContent(version: String) = CodeTransformChatMessageContent(
360-
message = message("codemodernizer.chat.message.enter_jdk_name", version),
361-
type = CodeTransformChatMessageType.FinalizedAnswer,
362-
)
359+
fun buildPromptTargetJDKNameChatContent(version: String, currentJdkName: String?): CodeTransformChatMessageContent {
360+
var message = message("codemodernizer.chat.message.enter_jdk_name", version)
361+
if (currentJdkName != null) {
362+
message += "\n\ncurrent: `$currentJdkName`"
363+
}
364+
return CodeTransformChatMessageContent(
365+
message = message,
366+
type = CodeTransformChatMessageType.FinalizedAnswer,
367+
)
368+
}
363369

364370
fun buildInvalidTargetJdkNameChatContent(jdkName: String) = CodeTransformChatMessageContent(
365371
message = message("codemodernizer.chat.message.enter_jdk_name_error", jdkName),

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class CodeTransformChatController(
138138
private val codeModernizerManager = CodeModernizerManager.getInstance(context.project)
139139
private val artifactHandler = ArtifactHandler(context.project, GumbyClient.getInstance(context.project), codeTransformChatHelper)
140140
private val telemetry = CodeTransformTelemetryManager.getInstance(context.project)
141+
private val jdkVersionToName = mutableMapOf<String, String>()
141142

142143
override suspend fun processChatPromptMessage(message: IncomingCodeTransformMessage.ChatPrompt) {
143144
if (chatSessionStorage.getSession(message.tabId).conversationState == CodeTransformConversationState.PROMPT_TARGET_JDK_NAME) {
@@ -456,6 +457,10 @@ class CodeTransformChatController(
456457
codeTransformChatHelper.addNewMessage(buildInvalidTargetJdkNameChatContent(providedJdkName))
457458
return
458459
}
460+
val jdkVersion = codeModernizerManager.codeTransformationSession?.sessionContext?.targetJavaVersion?.name
461+
if (jdkVersion != null) {
462+
jdkVersionToName[jdkVersion] = targetJdkName
463+
}
459464
codeModernizerManager.codeTransformationSession?.sessionContext?.targetJdkName = targetJdkName
460465
codeTransformChatHelper.addNewMessage(buildUserReplyChatContent(message.message.trim()))
461466
// start local build once we get target JDK path
@@ -506,7 +511,8 @@ dependencyManagement:
506511
private suspend fun promptForTargetJdkName(tabId: String) {
507512
chatSessionStorage.getSession(tabId).conversationState = CodeTransformConversationState.PROMPT_TARGET_JDK_NAME
508513
val targetJdkVersion = codeModernizerManager.codeTransformationSession?.sessionContext?.targetJavaVersion?.name.orEmpty()
509-
codeTransformChatHelper.addNewMessage(buildPromptTargetJDKNameChatContent(targetJdkVersion))
514+
val currentJdkName = jdkVersionToName[targetJdkVersion]
515+
codeTransformChatHelper.addNewMessage(buildPromptTargetJDKNameChatContent(targetJdkVersion, currentJdkName))
510516
codeTransformChatHelper.sendChatInputEnabledMessage(tabId, true)
511517
codeTransformChatHelper.sendUpdatePlaceholderMessage(tabId, "Enter the name of your $targetJdkVersion")
512518
}

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

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ import com.intellij.openapi.fileEditor.FileEditorManagerEvent
1616
import com.intellij.openapi.fileEditor.FileEditorManagerListener
1717
import com.intellij.openapi.fileEditor.TextEditor
1818
import com.intellij.openapi.project.Project
19+
import com.intellij.openapi.util.Disposer
1920
import com.intellij.openapi.util.Key
2021
import com.intellij.openapi.vfs.VirtualFile
2122
import com.intellij.openapi.vfs.VirtualFileManager
2223
import com.intellij.openapi.vfs.newvfs.BulkFileListener
2324
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
2425
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
2526
import kotlinx.coroutines.CoroutineScope
26-
import kotlinx.coroutines.delay
2727
import kotlinx.coroutines.launch
2828
import org.eclipse.lsp4j.DidChangeTextDocumentParams
2929
import org.eclipse.lsp4j.DidCloseTextDocumentParams
@@ -46,6 +46,7 @@ class TextDocumentServiceHandler(
4646
BulkFileListener,
4747
DocumentListener,
4848
Disposable {
49+
4950
init {
5051
// didOpen & didClose events
5152
project.messageBus.connect(this).subscribe(
@@ -68,9 +69,8 @@ class TextDocumentServiceHandler(
6869
// open files on startup
6970
cs.launch {
7071
val fileEditorManager = FileEditorManager.getInstance(project)
71-
fileEditorManager.openFiles.forEach { file ->
72+
fileEditorManager.selectedFiles.forEach { file ->
7273
handleFileOpened(file)
73-
delay(100)
7474
}
7575
}
7676
}
@@ -84,23 +84,33 @@ class TextDocumentServiceHandler(
8484
}
8585
ApplicationManager.getApplication().runReadAction {
8686
FileDocumentManager.getInstance().getDocument(file)?.addDocumentListener(listener)
87-
file.putUserData(KEY_REAL_TIME_EDIT_LISTENER, listener)
8887
}
89-
}
88+
file.putUserData(KEY_REAL_TIME_EDIT_LISTENER, listener)
89+
90+
Disposer.register(this) {
91+
ApplicationManager.getApplication().runReadAction {
92+
val existingListener = file.getUserData(KEY_REAL_TIME_EDIT_LISTENER)
93+
if (existingListener != null) {
94+
FileDocumentManager.getInstance().getDocument(file)?.removeDocumentListener(existingListener)
95+
file.putUserData(KEY_REAL_TIME_EDIT_LISTENER, null)
96+
}
97+
}
98+
}
9099

91-
cs.launch {
92-
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
93-
toUriString(file)?.let { uri ->
94-
languageServer.textDocumentService.didOpen(
95-
DidOpenTextDocumentParams().apply {
96-
textDocument = TextDocumentItem().apply {
97-
this.uri = uri
98-
text = file.inputStream.readAllBytes().decodeToString()
99-
languageId = file.fileType.name.lowercase()
100-
version = file.modificationStamp.toInt()
100+
cs.launch {
101+
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
102+
toUriString(file)?.let { uri ->
103+
languageServer.textDocumentService.didOpen(
104+
DidOpenTextDocumentParams().apply {
105+
textDocument = TextDocumentItem().apply {
106+
this.uri = uri
107+
text = file.inputStream.readAllBytes().decodeToString()
108+
languageId = file.fileType.name.lowercase()
109+
version = file.modificationStamp.toInt()
110+
}
101111
}
102-
}
103-
)
112+
)
113+
}
104114
}
105115
}
106116
}
@@ -116,6 +126,7 @@ class TextDocumentServiceHandler(
116126
textDocument = TextDocumentIdentifier().apply {
117127
this.uri = uri
118128
}
129+
// TODO: should respect `textDocumentSync.save.includeText` server capability config
119130
text = document.text
120131
}
121132
)
@@ -125,10 +136,12 @@ class TextDocumentServiceHandler(
125136
}
126137

127138
override fun after(events: MutableList<out VFileEvent>) {
128-
cs.launch {
129-
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
130-
events.filterIsInstance<VFileContentChangeEvent>().forEach { event ->
131-
val document = FileDocumentManager.getInstance().getCachedDocument(event.file) ?: return@forEach
139+
events.filterIsInstance<VFileContentChangeEvent>().forEach { event ->
140+
val document = FileDocumentManager.getInstance().getCachedDocument(event.file) ?: return@forEach
141+
142+
handleFileOpened(event.file)
143+
cs.launch {
144+
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
132145
toUriString(event.file)?.let { uri ->
133146
languageServer.textDocumentService.didChange(
134147
DidChangeTextDocumentParams().apply {
@@ -164,17 +177,18 @@ class TextDocumentServiceHandler(
164177
if (listener != null) {
165178
FileDocumentManager.getInstance().getDocument(file)?.removeDocumentListener(listener)
166179
file.putUserData(KEY_REAL_TIME_EDIT_LISTENER, null)
167-
}
168-
cs.launch {
169-
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
170-
toUriString(file)?.let { uri ->
171-
languageServer.textDocumentService.didClose(
172-
DidCloseTextDocumentParams().apply {
173-
textDocument = TextDocumentIdentifier().apply {
174-
this.uri = uri
180+
181+
cs.launch {
182+
AmazonQLspService.executeAsyncIfRunning(project) { languageServer ->
183+
toUriString(file)?.let { uri ->
184+
languageServer.textDocumentService.didClose(
185+
DidCloseTextDocumentParams().apply {
186+
textDocument = TextDocumentIdentifier().apply {
187+
this.uri = uri
188+
}
175189
}
176-
}
177-
)
190+
)
191+
}
178192
}
179193
}
180194
}
@@ -185,10 +199,12 @@ class TextDocumentServiceHandler(
185199
}
186200

187201
private fun handleActiveEditorChange(fileEditor: FileEditor?) {
202+
val editor = (fileEditor as? TextEditor)?.editor ?: return
203+
editor.virtualFile?.let { handleFileOpened(it) }
204+
188205
// Extract text editor if it's a TextEditor, otherwise null
189-
val editor = (fileEditor as? TextEditor)?.editor
190-
val textDocumentIdentifier = editor?.let { TextDocumentIdentifier(toUriString(it.virtualFile)) }
191-
val cursorState = editor?.let { getCursorState(it) }
206+
val textDocumentIdentifier = TextDocumentIdentifier(toUriString(editor.virtualFile))
207+
val cursorState = getCursorState(editor)
192208

193209
val params = mapOf(
194210
"textDocument" to textDocumentIdentifier,

0 commit comments

Comments
 (0)