Skip to content

Commit

Permalink
fix: removal of delicate api, using CoroutineScope instead
Browse files Browse the repository at this point in the history
  • Loading branch information
alashchev17 committed Oct 28, 2024
1 parent 738d421 commit c8b4dc3
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class CodeLensAction(
.replace("%CODE_SELECTION%", text)
}

@OptIn(DelicateCoroutinesApi::class)
fun actionPerformed() {
val chat = editor.project?.let { ToolWindowManager.getInstance(it).getToolWindow("Refact") }
chat?.activate {
Expand All @@ -52,17 +51,15 @@ class CodeLensAction(

// If content is empty, then it's "Open Chat" instruction, selecting range of code in active tab
if (contentMsg.isEmpty()) {
GlobalScope.launch {
CoroutineScope(Dispatchers.Main).launch {
delay(500)
withContext(Dispatchers.Main) {
val pos1 = LogicalPosition(line1, 0)
val pos2 = LogicalPosition(line2, editor.document.getLineEndOffset(line2))
val pos1 = LogicalPosition(line1, 0)
val pos2 = LogicalPosition(line2, editor.document.getLineEndOffset(line2))

editor.selectionModel.setSelection(
editor.logicalPositionToOffset(pos1),
editor.logicalPositionToOffset(pos2)
)
}
editor.selectionModel.setSelection(
editor.logicalPositionToOffset(pos1),
editor.logicalPositionToOffset(pos2)
)
}
}
}
Expand Down

0 comments on commit c8b4dc3

Please sign in to comment.