From a53f92432b318a55b8697a8759382384704b23cb Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Tue, 7 Jan 2025 19:45:41 -0800 Subject: [PATCH] keybinding for ctrl+L and ctrl+K shows accurately even if user changes it --- .../contrib/void/browser/helpers/getCmdKey.ts | 20 ------------------- .../src/quick-edit-tsx/QuickEditChat.tsx | 10 +++++++--- .../react/src/sidebar-tsx/SidebarChat.tsx | 6 ++++-- .../void/browser/react/src/util/services.tsx | 2 ++ 4 files changed, 13 insertions(+), 25 deletions(-) delete mode 100644 src/vs/workbench/contrib/void/browser/helpers/getCmdKey.ts diff --git a/src/vs/workbench/contrib/void/browser/helpers/getCmdKey.ts b/src/vs/workbench/contrib/void/browser/helpers/getCmdKey.ts deleted file mode 100644 index fe520e42..00000000 --- a/src/vs/workbench/contrib/void/browser/helpers/getCmdKey.ts +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Glass Devtools, Inc. All rights reserved. - * Void Editor additions licensed under the AGPL 3.0 License. - *--------------------------------------------------------------------------------------------*/ - -import { isMacintosh } from '../../../../../base/common/platform.js'; - -// import { OperatingSystem, OS } from '../../../../base/common/platform.js'; -// OS === OperatingSystem.Macintosh -export function getCmdKey(): string { - if (isMacintosh) { - return '⌘'; - } else { - return 'Ctrl'; - } -} - - - - diff --git a/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx index 26bbc9f9..4d67a861 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx @@ -7,9 +7,8 @@ import React, { FormEvent, useCallback, useEffect, useRef, useState } from 'reac import { useSettingsState, useSidebarState, useThreadsState, useQuickEditState, useAccessor } from '../util/services.js'; import { OnError } from '../../../../../../../platform/void/common/llmMessageTypes.js'; import { InputBox } from '../../../../../../../base/browser/ui/inputbox/inputBox.js'; -import { getCmdKey } from '../../../helpers/getCmdKey.js'; import { VoidInputBox } from '../util/inputs.js'; -import { QuickEditPropsType } from '../../../quickEditActions.js'; +import { QuickEditPropsType, VOID_CTRL_K_ACTION_ID } from '../../../quickEditActions.js'; import { ButtonStop, ButtonSubmit } from '../sidebar-tsx/SidebarChat.js'; import { ModelDropdown } from '../void-settings-tsx/ModelDropdown.js'; import { X } from 'lucide-react'; @@ -72,6 +71,7 @@ export const QuickEditChat = ({ diffareaid, onGetInputBox, onUserUpdateText, onC inlineDiffsService.removeCtrlKZone({ diffareaid }) }, [inlineDiffsService, diffareaid]) + // sync init value const alreadySetRef = useRef(false) useEffect(() => { @@ -81,6 +81,10 @@ export const QuickEditChat = ({ diffareaid, onGetInputBox, onUserUpdateText, onC inputBoxRef.current.value = instructions }, [initText, instructions]) + const keybindingString = accessor.get('IKeybindingService').lookupKeybinding(VOID_CTRL_K_ACTION_ID)?.getLabel() + + + return
{/* text input */} { inputBoxRef.current = instance; diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index e1fc9fc4..329724d6 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -16,7 +16,6 @@ import { EndOfLinePreference } from '../../../../../../../editor/common/model.js import { IDisposable } from '../../../../../../../base/common/lifecycle.js'; import { ErrorDisplay } from './ErrorDisplay.js'; import { OnError, ServiceSendLLMMessageParams } from '../../../../../../../platform/void/common/llmMessageTypes.js'; -import { getCmdKey } from '../../../helpers/getCmdKey.js' import { HistoryInputBox, InputBox } from '../../../../../../../base/browser/ui/inputbox/inputBox.js'; import { VoidInputBox } from '../util/inputs.js'; import { ModelDropdown } from '../void-settings-tsx/ModelDropdown.js'; @@ -26,6 +25,7 @@ import { ILLMMessageService } from '../../../../../../../platform/void/common/ll import { IModelService } from '../../../../../../../editor/common/services/model.js'; import { SidebarThreadSelector } from './SidebarThreadSelector.js'; import { useScrollbarStyles } from '../util/useScrollbarStyles.js'; +import { VOID_CTRL_L_ACTION_ID } from '../../../sidebarActions.js'; const IconX = ({ size, className = '', ...props }: { size: number, className?: string } & React.SVGProps) => { @@ -577,6 +577,8 @@ export const SidebarChat = () => { // const [_test_messages, _set_test_messages] = useState([]) + const keybindingString = accessor.get('IKeybindingService').lookupKeybinding(VOID_CTRL_L_ACTION_ID)?.getLabel() + return
{ {/* text input */} { ILanguageConfigurationService: accessor.get(ILanguageConfigurationService), ILanguageDetectionService: accessor.get(ILanguageDetectionService), ILanguageFeaturesService: accessor.get(ILanguageFeaturesService), + IKeybindingService: accessor.get(IKeybindingService), } as const return reactAccessor