Skip to content

Commit

Permalink
cancel edit, don't regenerate when the same content
Browse files Browse the repository at this point in the history
3.15.3
  • Loading branch information
rjmacarthy committed Aug 16, 2024
1 parent 744f442 commit 36e648b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "twinny",
"displayName": "twinny - AI Code Completion and Chat",
"description": "Locally hosted AI code completion plugin for vscode",
"version": "3.15.2",
"version": "3.15.3",
"icon": "assets/icon.png",
"keywords": [
"code-inference",
Expand Down
31 changes: 24 additions & 7 deletions src/webview/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ export const Message = ({

const handleRegenerate = () => onRegenerate?.(index)

const handleToggleCancel = () => {
setEditing(false)
editor?.commands.setContent(message.content as string)
}

const handleToggleSave = () => {
const content = editor?.storage.markdown.getMarkdown()
if (message.content === content) {
return setEditing(false)
}
onUpdate?.(content || '', index)
setEditing(false)
}
Expand Down Expand Up @@ -105,13 +113,22 @@ export const Message = ({
<span>{message.role === ASSISTANT ? TWINNY : YOU}</span>
<div className={styles.messageOptions}>
{editing && !isAssistant && (
<VSCodeButton
title="Save message"
appearance="icon"
onClick={handleToggleSave}
>
<span className="codicon codicon-check"></span>
</VSCodeButton>
<>
<VSCodeButton
title="Cancel edit"
appearance="icon"
onClick={handleToggleCancel}
>
<span className="codicon codicon-close"></span>
</VSCodeButton>
<VSCodeButton
title="Save message"
appearance="icon"
onClick={handleToggleSave}
>
<span className="codicon codicon-check"></span>
</VSCodeButton>
</>
)}
{!editing && !isAssistant && (
<>
Expand Down

0 comments on commit 36e648b

Please sign in to comment.