Skip to content

Commit

Permalink
fix: resolve issue where arrow keys and enter do not select suggestio…
Browse files Browse the repository at this point in the history
…n and send

Signed-off-by: DingChil <[email protected]>
  • Loading branch information
DingChil committed Oct 30, 2023
1 parent bba88a7 commit 90a2df1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
3 changes: 3 additions & 0 deletions assets/styles/csui-reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#webpilot-content {
p {
color: #dcdcdc;
}
li {
color: #dcdcdc;
}
code {
background: #002b36;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webpilot",
"version": "0.9.1025",
"version": "0.9.1030",
"author": "webpilot.ai",
"displayName": "Webpilot - Copilot for All, Free & Open",
"description": "__MSG_extensionDescription__",
Expand Down
28 changes: 11 additions & 17 deletions src/csui/Index/ThePopupBox/ThePopupBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
[$style['container--joint']]: showMenu || (!showResult && showPrompts),
}"
>
<!-- [$style.showPromptEditor]: showEditor,
<HeaderPanel @on-close="handleClosePopup" /> -->
<!-- <PromptList
v-if="showPrompts"
:prompts="currentPromptsList"
:selected-index="selectedPrompt.index"
@on-add-prompt="handleAddPrompt"
@on-change="handleChangePrompt"
@on-edit-prompt="handleEditPrompt"
/> -->
<PromptInput
v-model="inputCommand"
:disabled="aiThinking || generating"
Expand Down Expand Up @@ -134,20 +124,24 @@ useMagicKeys({
// control prompts list
if (!showPrompts.value) return
const index = chooseIndex.value
const {length} = currentPromptsList
const oldIndex = chooseIndex.value
const {length} = currentPromptsList.value
if (e.key === 'ArrowUp' && e.type === 'keyup') {
e.preventDefault()
chooseIndex.value = index - 1 < 0 ? length - 1 : index - 1
const newIndex = oldIndex - 1 < 0 ? length - 1 : oldIndex - 1
chooseIndex.value = newIndex
inputCommand.value = currentPromptsList.value[newIndex].command
}
if (e.key === 'ArrowDown' && e.type === 'keyup') {
e.preventDefault()
chooseIndex.value = index + 1 >= length ? 0 : index + 1
const newIndex = oldIndex + 1 >= length ? 0 : oldIndex + 1
chooseIndex.value = newIndex
inputCommand.value = currentPromptsList.value[newIndex].command
}
if (e.key === 'Enter' && e.type === 'keyup') {
e.preventDefault()
if (index === -1) popUpAskAi()
else handleChangePrompt({index, prompt: currentPromptsList[index]})
if (oldIndex === -1) popUpAskAi()
else handleChangePrompt({index: oldIndex, prompt: currentPromptsList.value[oldIndex]})
}
},
})
Expand Down Expand Up @@ -335,8 +329,8 @@ const handleShowMenu = () => {
const handleChangePrompt = promptInfo => {
const {index, prompt} = promptInfo
selectedPrompt.index = index
chooseIndex.value = index
selectedPrompt.prompt = prompt
chooseIndex.value = index
inputCommand.value = prompt.command
store.updateConfig({[currentPromptsIndexName.value]: index})
Expand Down

0 comments on commit 90a2df1

Please sign in to comment.