Skip to content

Commit

Permalink
Fixed missing chat history shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanger2000 committed Mar 27, 2023
1 parent 5cd4edd commit 66f0989
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/appComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ export function App() {
} else if (e.key == 'e' && e.shiftKey) {
dispatch(ct.pressAICommand('singleLSP'))
e.stopPropagation()
} else if (e.key == 'h') {
dispatch(ct.pressAICommand('history'))
e.stopPropagation()
}
}

Expand Down
24 changes: 11 additions & 13 deletions src/features/chat/chatThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
setCurrentDraftMessage,
setGenerating,
startNewMessage,
toggleChatHistory,
tokenLimitInterrupt,
updateLastUserMessageMsgType,
} from './chatSlice'
Expand Down Expand Up @@ -1111,7 +1112,8 @@ export const pressAICommand = createAsyncThunk(
| 'l'
| 'Enter'
| 'Backspace'
| 'singleLSP',
| 'singleLSP'
| 'history',
{ getState, dispatch }
) => {
// If currently responding to a chat, make this a chat_edit response
Expand All @@ -1134,6 +1136,9 @@ export const pressAICommand = createAsyncThunk(
return
}
switch (keypress) {
case 'history':
dispatch(toggleChatHistory())
return
case 'Enter':
// Need to be in diff state or diff accept state
if (
Expand Down Expand Up @@ -1228,19 +1233,11 @@ export const pressAICommand = createAsyncThunk(
case 'k':
if (chatState.chatIsOpen && lastBotMessage?.finished) {
if (editorView) {
// Check if editorView in focus
if (!editorView.hasFocus) {
// When there is an editorView not in focus, we dispatch this
dispatch(changeMsgType('chat_edit'))
dispatch(changeDraftMsgType('chat_edit'))
return
}
// When there is an editorView, we dispatch something
dispatch(changeMsgType('chat_edit'))
dispatch(changeDraftMsgType('chat_edit'))
}
// Close the chat if the chat is open then
dispatch(setChatOpen(false))
}

if (editorView) {
} else if (editorView) {
const selPos = getSelectedPos(editorView)
const selection = editorView.state.selection.main
editorView.dispatch({
Expand Down Expand Up @@ -1359,3 +1356,4 @@ export const submitCommandBar = thunkFactory(
dummySubmitCommandBar,
'submitCommandBar'
)

0 comments on commit 66f0989

Please sign in to comment.