Merge pull request #2624 from continuedev/pe/jb-esc-fix

bugfix(jb): dont override `esc` key globally
This commit is contained in:
Patrick Erichsen 2024-10-22 11:45:23 -07:00 • committed by GitHub
commit 78d00719ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 20 deletions

View file

@ -1,8 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Continue" type="CompoundRunConfigurationType">
<toRun name="Run Extension" type="GradleRunConfiguration" />
<toRun name="GUI: Start Dev Server" type="js.build_tools.npm" />
<toRun name="Tail Dev Logs" type="ShConfigurationType" />
<method v="2" />
</configuration>
</component>

View file

@ -1,21 +1,30 @@
package com.github.continuedev.continueintellijextension.autocomplete
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.service
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.actionSystem.EditorAction
import com.intellij.openapi.editor.actionSystem.EditorActionHandler
import com.intellij.openapi.project.Project
class CancelAutocompleteAction : EditorAction(object : EditorActionHandler() {
override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) {
ApplicationManager.getApplication().runWriteAction {
editor.project?.service<AutocompleteService>()?.clearCompletions(editor)
class CancelAutocompleteAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
if (isInvokedInEditor(e)) {
val editor = e.getRequiredData(CommonDataKeys.EDITOR)
ApplicationManager.getApplication().runWriteAction {
editor.project?.service<AutocompleteService>()?.clearCompletions(editor)
}
}
}
override fun isEnabledForCaret(editor: Editor, caret: Caret, dataContext: DataContext?): Boolean {
return true
override fun update(e: AnActionEvent) {
e.presentation.isEnabledAndVisible = isInvokedInEditor(e)
}
}) {}
private fun isInvokedInEditor(e: AnActionEvent): Boolean {
val project: Project? = e.project
val editor: Editor? = e.getData(CommonDataKeys.EDITOR)
return project != null && editor != null && editor.contentComponent.hasFocus()
}
}

View file

@ -191,7 +191,9 @@ fun openInlineEdit(project: Project?, editor: Editor) {
editor,
startLineNumber,
endLineNumber,
{ inlayRef.get().dispose() },
{
inlayRef.get()?.dispose()
},
{
textArea.document.insertString(textArea.caretPosition, ", ", null)
textArea.requestFocus()