From 6630d596f6789ec14822dd7387d2b30f78fcc9ba Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sat, 21 Dec 2024 22:40:06 -0800 Subject: [PATCH] code box UI --- .../browser/react/src/markdown/BlockCode.tsx | 12 +--------- .../void/browser/react/src/util/inputs.tsx | 23 +++++++++++++++---- .../contrib/void/browser/voidSettingsPane.ts | 20 ++++++++++++---- 3 files changed, 35 insertions(+), 20 deletions(-) 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 46f9e086..14328b5c 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 @@ -4,8 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import React, { ReactNode } from "react" -import SyntaxHighlighter from "react-syntax-highlighter"; -import { atomOneDarkReasonable } from "react-syntax-highlighter/dist/esm/styles/hljs"; import { VoidCodeEditor } from '../util/inputs.js'; @@ -71,19 +69,11 @@ export function getLanguageFromFileName(fileName: string): string { export const BlockCode = ({ text, buttonsOnHover, language }: { text: string, buttonsOnHover?: ReactNode, language?: string }) => { - const customStyle = { - ...atomOneDarkReasonable, - 'code[class*="language-"]': { - ...atomOneDarkReasonable['code[class*="language-"]'], - background: "none", - }, - } - return (<>
{buttonsOnHover === null ? null : ( -
+
{buttonsOnHover}
)} diff --git a/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx b/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx index 557d4dca..260f8c75 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx @@ -299,6 +299,7 @@ export const VoidCodeEditor = ({ initValue, language }: { initValue: string, lan return
instantiationService.createInstance( CodeEditorWidget, @@ -306,22 +307,34 @@ export const VoidCodeEditor = ({ initValue, language }: { initValue: string, lan { automaticLayout: true, wordWrap: 'off', + scrollbar: { + alwaysConsumeMouseWheel: false, vertical: 'auto', horizontal: 'auto', - alwaysConsumeMouseWheel: false }, + scrollBeyondLastLine: false, + lineNumbers: 'off', + + readOnly: true, + domReadOnly: true, + readOnlyMessage: { value: '' }, + + minimap: { + enabled: false, + // maxColumn: 0, + }, + + selectionHighlight: false, // highlights whole words + renderLineHighlight: 'none', + folding: false, lineDecorationsWidth: 0, - scrollBeyondLastLine: false, - minimap: { enabled: false }, overviewRulerLanes: 0, hideCursorInOverviewRuler: true, overviewRulerBorder: false, - renderLineHighlight: 'none', glyphMargin: false, - readOnly: true, }, { isSimpleWidget: true, diff --git a/src/vs/workbench/contrib/void/browser/voidSettingsPane.ts b/src/vs/workbench/contrib/void/browser/voidSettingsPane.ts index b1fc7372..51803ce2 100644 --- a/src/vs/workbench/contrib/void/browser/voidSettingsPane.ts +++ b/src/vs/workbench/contrib/void/browser/voidSettingsPane.ts @@ -35,10 +35,11 @@ class VoidSettingsInput extends EditorInput { static readonly ID: string = 'workbench.input.void.settings'; - readonly resource = URI.from({ - scheme: 'void-editor-settings', - path: 'void-settings' // Give it a unique path - }); + static readonly RESOURCE = URI.from({ // I think this scheme is invalid, it just shuts up TS + scheme: 'void', // Custom scheme for our editor + path: 'settings' + }) + readonly resource = VoidSettingsInput.RESOURCE; constructor() { super(); @@ -140,9 +141,20 @@ registerAction2(class extends Action2 { ] }); } + async run(accessor: ServicesAccessor): Promise { const editorService = accessor.get(IEditorService); const instantiationService = accessor.get(IInstantiationService); + + const openEditors = editorService.findEditors(VoidSettingsInput.RESOURCE); + + // close all instances if found + if (openEditors.length > 0) { + await editorService.closeEditors(openEditors); + return; + } + + // else open it const input = instantiationService.createInstance(VoidSettingsInput); await editorService.openEditor(input); }