From 1afb39b1558491413fb8877a32800d6e3efabb98 Mon Sep 17 00:00:00 2001 From: mp Date: Tue, 24 Dec 2024 02:22:45 -0800 Subject: [PATCH] minor changes --- .../void/browser/autocompleteService.ts | 18 +++-------- .../browser/react/src/markdown/BlockCode.tsx | 30 +++++++++++-------- .../react/src/markdown/ChatMarkdownRender.tsx | 4 +-- .../browser/react/src/sidebar-tsx/Sidebar.tsx | 2 +- .../react/src/sidebar-tsx/SidebarChat.tsx | 4 +-- .../react/src/void-settings-tsx/Settings.tsx | 2 +- 6 files changed, 27 insertions(+), 33 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/autocompleteService.ts b/src/vs/workbench/contrib/void/browser/autocompleteService.ts index 649b310c..9d54fcb9 100644 --- a/src/vs/workbench/contrib/void/browser/autocompleteService.ts +++ b/src/vs/workbench/contrib/void/browser/autocompleteService.ts @@ -165,20 +165,6 @@ const postprocessResult = (result: string) => { } -const extractCodeFromResult = (result: string) => { - // Match either: - // 1. ```language\n``` - // 2. `````` - const match = result.match(/```(?:\w+\n)?([\s\S]*?)```|```([\s\S]*?)```/); - - if (!match) { - return result; - } - - // Return whichever group matched (non-empty) - return match[1] ?? match[2] ?? result; -} - // trims the end of the prefix to improve cache hit rate const removeLeftTabsAndTrimEnd = (s: string): string => { @@ -768,3 +754,7 @@ export class AutocompleteService extends Disposable implements IAutocompleteServ registerSingleton(IAutocompleteService, AutocompleteService, InstantiationType.Eager); +function extractCodeFromResult(fullText: string): string { + throw new Error('Function not implemented.'); +} + diff --git a/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx b/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx index 6d4817c0..d3e5e5ed 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx @@ -8,6 +8,22 @@ import { VoidCodeEditor } from '../util/inputs.js'; import { ILanguageService } from '../../../../../../../editor/common/languages/language.js'; +export const extractCodeFromResult = (result: string) => { + // Match either: + // 1. ```language\n``` + // 2. `````` + const match = result.match(/```(?:\w+\n)?([\s\S]*?)```|```([\s\S]*?)```/); + + if (!match) { + return result; + } + + // Return whichever group matched (non-empty) + return match[1] ?? match[2] ?? result; +} + + + const extensionMap: { [key: string]: string } = { // Web 'html': 'html', @@ -71,7 +87,7 @@ export const BlockCode = ({ text, buttonsOnHover, language }: { text: string, bu {buttonsOnHover === null ? null : (
-
{buttonsOnHover}
+
{buttonsOnHover}
)} @@ -79,18 +95,6 @@ export const BlockCode = ({ text, buttonsOnHover, language }: { text: string, bu initValue={text} language={language} /> - {/*
- - {text} - - -
*/} ) diff --git a/src/vs/workbench/contrib/void/browser/react/src/markdown/ChatMarkdownRender.tsx b/src/vs/workbench/contrib/void/browser/react/src/markdown/ChatMarkdownRender.tsx index 6cda2ed6..73c7160d 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/markdown/ChatMarkdownRender.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/markdown/ChatMarkdownRender.tsx @@ -40,13 +40,13 @@ const CodeButtonsOnHover = ({ diffRepr: text }: { diffRepr: string }) => { return <>