Skip to content

Commit

Permalink
fix/editor: Ask Cody to Fix no longer throws exceptions in TypeScript…
Browse files Browse the repository at this point in the history
… files (#6473)

Fixes CODY-4573.

The exception in that bug happened because
`TypeScriptLanguageServiceFix.getFamilyName` could block the thread, but
we were calling it on EDT. The fix is to simply check that the action is
related to Cody before drilling down into the name.

In theory any accessor on highlights could be poorly implemented, but in
practice Ask Cody to Fix works in TypeScript files now so this is an
improvement.

## Test plan

```
cd jetbrains
SKIP_CODE_SEARCH_BUILD=true ./gradlew :customRunIde \
    -PforceAgentBuild=true \
    -PplatformRuntimeType=WS -PplatformRuntimeVersion=2024.3
```

- Create or open a TypeScript file. Enter some nonsense like `function
f(s: string, s: number) {`
- Use the lightbulb hover, or press Alt-Enter to show quick actions.
- "Ask Cody to Fix"
- Verify that the feature works and there's no IllegalStateException
exceptions

![Screenshot 2024-12-27 at 15 47
23](https://github.com/user-attachments/assets/536ce0e7-3d0c-4010-9c65-33ec8a318eeb)
  • Loading branch information
dominiccooney authored Dec 27, 2024
1 parent 1afb0e9 commit 91ac295
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CodyFixHighlightPass(val file: PsiFile, val editor: Editor) :
@RequiresEdt
override fun doApplyInformationToEditor() {
for (highlight in myHighlights) {
highlight.unregisterQuickFix { it.familyName == CodeActionQuickFix.FAMILY_NAME }
highlight.unregisterQuickFix { (it as? CodeActionQuickFix)?.familyName == CodeActionQuickFix.FAMILY_NAME }

if (highlight.startOffset > document.textLength ||
highlight.endOffset > document.textLength ||
Expand Down

0 comments on commit 91ac295

Please sign in to comment.