File tree Expand file tree Collapse file tree 4 files changed +57
-9
lines changed Expand file tree Collapse file tree 4 files changed +57
-9
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " bugfix" ,
3
+ "description" : " Fix unsupported files being shown in file picker when selecting images for adding image context in Windows"
4
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ package software.aws.toolkits.jetbrains.services.amazonq.lsp.util
5
+
6
+ import com.intellij.openapi.fileChooser.FileChooserDescriptor
7
+
8
+ /* *
9
+ * Applies file extension filtering to the given FileChooserDescriptor for IntelliJ Platform versions before 2024.3 (baseline < 243).
10
+ * Uses withFileFilter method which provides filtering functionality but doesn't visually filter
11
+ * files in the chooser dialog.
12
+ *
13
+ * @param descriptor The FileChooserDescriptor to apply filtering to
14
+ * @param filterName The display name for the filter (e.g., "Images") - unused in this version
15
+ * @param allowedExtensions Set of allowed file extensions (e.g., "jpg", "png")
16
+ * @return The modified FileChooserDescriptor
17
+ */
18
+ fun applyExtensionFilter (
19
+ descriptor : FileChooserDescriptor ,
20
+ @Suppress(" UNUSED_PARAMETER" ) filterName : String ,
21
+ allowedExtensions : Set <String >,
22
+ ): FileChooserDescriptor = descriptor.withFileFilter { virtualFile ->
23
+ if (virtualFile.isDirectory) {
24
+ true // Always allow directories for navigation
25
+ } else {
26
+ val extension = virtualFile.extension?.lowercase()
27
+ extension != null && allowedExtensions.contains(extension)
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ package software.aws.toolkits.jetbrains.services.amazonq.lsp.util
5
+
6
+ import com.intellij.openapi.fileChooser.FileChooserDescriptor
7
+
8
+ /* *
9
+ * Applies file extension filtering to the given FileChooserDescriptor for IntelliJ Platform versions 2024.3+ (baseline >= 243).
10
+ * Uses withExtensionFilter method which provides both filtering functionality and visual
11
+ * filtering in the chooser dialog.
12
+ *
13
+ * @param descriptor The FileChooserDescriptor to apply filtering to
14
+ * @param filterName The display name for the filter (e.g., "Images")
15
+ * @param allowedExtensions Set of allowed file extensions (e.g., "jpg", "png")
16
+ * @return The modified FileChooserDescriptor
17
+ */
18
+ fun applyExtensionFilter (
19
+ descriptor : FileChooserDescriptor ,
20
+ filterName : String ,
21
+ allowedExtensions : Set <String >,
22
+ ): FileChooserDescriptor = descriptor.withExtensionFilter(filterName, * allowedExtensions.toTypedArray())
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ShowS
66
66
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.ConnectionMetadata
67
67
import software.aws.toolkits.jetbrains.services.amazonq.lsp.util.LspEditorUtil
68
68
import software.aws.toolkits.jetbrains.services.amazonq.lsp.util.TelemetryParsingUtil
69
+ import software.aws.toolkits.jetbrains.services.amazonq.lsp.util.applyExtensionFilter
69
70
import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererModelConfigurator
70
71
import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService
71
72
import software.aws.toolkits.jetbrains.settings.CodeWhispererSettings
@@ -311,15 +312,7 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
311
312
if (params.filters.isNotEmpty() && ! params.canSelectFolders) {
312
313
// Create a combined list of all allowed extensions
313
314
val allowedExtensions = params.filters.values.flatten().toSet()
314
-
315
- withFileFilter { virtualFile ->
316
- if (virtualFile.isDirectory) {
317
- true // Always allow directories for navigation
318
- } else {
319
- val extension = virtualFile.extension?.lowercase()
320
- extension != null && allowedExtensions.contains(extension)
321
- }
322
- }
315
+ applyExtensionFilter(this , " Images" , allowedExtensions)
323
316
}
324
317
}
325
318
You can’t perform that action at this time.
0 commit comments