Skip to content

Commit 5c4d72e

Browse files
authored
fix(codewhisperer): Cloud9 alt+c keybinding fails
Problem: - `setContext` is not supported in Cloud9, so `CODEWHISPERER_ENABLED` is always false in package.json. - Parentheses can't be used for logical grouping in the "when" clause (confirmed on the latest Cloud9, which uses vscode 1.68 extension host). Solution: - Check for `isCloud9` and other flags a workaround. - Use redundant logic to workaround the lack of parentheses support.
1 parent c92c522 commit 5c4d72e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,13 +3856,13 @@
38563856
"command": "aws.codeWhisperer",
38573857
"key": "alt+c",
38583858
"mac": "alt+c",
3859-
"when": "editorTextFocus && CODEWHISPERER_ENABLED"
3859+
"when": "editorTextFocus && CODEWHISPERER_ENABLED || isCloud9 && editorTextFocus"
38603860
},
38613861
{
38623862
"command": "aws.codeWhisperer.rejectCodeSuggestion",
38633863
"key": "escape",
38643864
"mac": "escape",
3865-
"when": "inlineSuggestionVisible && !editorReadonly && CODEWHISPERER_ENABLED"
3865+
"when": "inlineSuggestionVisible && !editorReadonly && CODEWHISPERER_ENABLED || isCloud9 && suggestWidgetVisible && !editorReadonly"
38663866
},
38673867
{
38683868
"key": "right",

src/codewhisperer/commands/invokeRecommendation.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ export async function invokeRecommendation(
5757
}
5858

5959
if (isCloud9('any')) {
60+
// C9 manual trigger key alt/option + C is ALWAYS enabled because the VSC version C9 is on doesn't support setContextKey which is used for CODEWHISPERER_ENABLED
61+
// therefore we need a connection check if there is ANY connection(regardless of the connection's state) connected to CodeWhisperer on C9
62+
if (!AuthUtil.instance.isConnected()) {
63+
return
64+
}
65+
6066
if (RecommendationHandler.instance.isGenerateRecommendationInProgress) {
6167
return
6268
}

0 commit comments

Comments
 (0)