-
Notifications
You must be signed in to change notification settings - Fork 272
Replace old actions with new actions that have configurable key bindings #4914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
<action id="codewhisperer.inline.accept" | ||
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererAcceptAction" | ||
text="Accept the Current Inline Suggestion" description="Accept the current inline suggestions"> | ||
<keyboard-shortcut keymap="$default" first-keystroke="TAB"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm a bit worried about the interaction between this and the IDE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic will be what the promoter does -- when the CW is showing:
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
it will be promoted to CW accept.
Otherwise it will be IDE tab action.
.../software/aws/toolkits/jetbrains/services/codewhisperer/actions/CodeWhispererAcceptAction.kt
Outdated
Show resolved
Hide resolved
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus | ||
import software.aws.toolkits.resources.message | ||
|
||
open class CodeWhispererAcceptAction(title: String = message("codewhisperer.inline.accept")) : AnAction(title), DumbAware { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sealed and move the force action here since there is no difference except the key binding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like I can't make CodeWhispererAcceptAction as sealed class because I will be getting this error:
Caused by: java.lang.NullPointerException: null cannot be cast to non-null type software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererAcceptAction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failing lint
needs will or someone else to ack
probably should target a feature branch instead of main
run { | ||
// TODO: Doesn't reflect dynamically if users change but didn't restart IDE | ||
val shortcut = ActionManager.getInstance().getAction("codewhisperer.inline.navigate.next") | ||
.shortcutSet.shortcuts.first() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will throw if user somehow removed shortcut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not
KeymapUtil.getFirstKeyboardShortcutText
or getPrimaryShortcut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testing
if (SystemInfo.isMac) { | ||
MacKeymapUtil.getKeyStrokeText(keyStroke, " ", true) | ||
} else { | ||
KeymapUtil.getKeystrokeText(keyStroke) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we actually need a space delim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I tried without space delim it looks a bit weird
// workaround for certain cases for sometimes the string is not input there | ||
EdtExecutorService.getScheduledExecutorInstance().schedule({ | ||
settings.select(configurable, Q_INLINE_KEYBINDING_SEARCH_TEXT) | ||
}, 500, TimeUnit.MILLISECONDS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels like this should not be required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last time I checked if I don't have this, it won't input the text in the keymap setting bar, I will try again later
val settings = DataManager.getInstance().getDataContext(e.source as ActionLink).getData(Settings.KEY) ?: return@link | ||
val configurable: Configurable = settings.find("preferences.keymap") ?: return@link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user needs feedback if these are null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add a TODO for now, can't think of a best way to inform users failures in this case
) | ||
enabled(invoke) | ||
}.comment(message("aws.settings.codewhisperer.project_context_index_thread.tooltip")) | ||
}.comment(message("aws.settings.codewhisperer.project_context_index_thread.tooltip"), maxLineLength = 47) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does magic number come from
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will just remove it for now.
override fun update(e: AnActionEvent) { | ||
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null && | ||
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
override fun update(e: AnActionEvent) { | |
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null && | |
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() | |
} | |
override fun update(e: AnActionEvent) { | |
e.presentation.isEnabled = e.project != null && | |
e.getData(CommonDataKeys.EDITOR) != null && | |
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() | |
} |
override fun update(e: AnActionEvent) { | ||
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null && | ||
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
e.project != null &&
e.getData(CommonDataKeys.EDITOR) != null &&
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
ApplicationManager.getApplication().messageBus.syncPublisher( | ||
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED | ||
).navigateNext(sessionContext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to this PR tho, i feel we could make this messagebus a project level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prob doesn't matter since we aren't going to have multple display sessions across different projects
1. Accept (Tab) 2. Force Accept (Opt + Tab/Opt + Enter) 3. Navigate to Previous (Opt + [) 4. Navigate to Next (Opt + ])
Notes:
sessionContext
(a new data class inCodeWhispererModel.kt
) andisDisplaySessionActive()
(checks if we are showing codewhisperer) will be introduced in the following PRs.Types of changes
Description
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.