From 36e648b208bb49ee31eba713fd716573018c6757 Mon Sep 17 00:00:00 2001 From: rjmacarthy Date: Fri, 16 Aug 2024 13:09:28 +0100 Subject: [PATCH] cancel edit, don't regenerate when the same content 3.15.3 --- package-lock.json | 4 ++-- package.json | 2 +- src/webview/message.tsx | 31 ++++++++++++++++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index ac7ebe9e..ac9c9004 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "twinny", - "version": "3.15.2", + "version": "3.15.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "twinny", - "version": "3.15.2", + "version": "3.15.3", "cpu": [ "x64", "arm64" diff --git a/package.json b/package.json index e08035d6..3116b379 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/webview/message.tsx b/src/webview/message.tsx index 44df373a..6c6d777b 100644 --- a/src/webview/message.tsx +++ b/src/webview/message.tsx @@ -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) } @@ -105,13 +113,22 @@ export const Message = ({ {message.role === ASSISTANT ? TWINNY : YOU}
{editing && !isAssistant && ( - - - + <> + + + + + + + )} {!editing && !isAssistant && ( <>