From 4b40ac1b47bcd6f2a9c914a2699afb9dd655698f Mon Sep 17 00:00:00 2001 From: Mathew Pareles Date: Tue, 6 May 2025 04:33:48 -0700 Subject: [PATCH] commandbar decent draft --- .../contrib/void/browser/editCodeService.ts | 21 +++---- .../void/browser/editCodeServiceInterface.ts | 2 + .../VoidCommandBar.tsx | 56 ++++++++++++++++--- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/editCodeService.ts b/src/vs/workbench/contrib/void/browser/editCodeService.ts index 56e89cf5..6bb52d7e 100644 --- a/src/vs/workbench/contrib/void/browser/editCodeService.ts +++ b/src/vs/workbench/contrib/void/browser/editCodeService.ts @@ -269,7 +269,11 @@ class EditCodeService extends Disposable implements IEditCodeService { } - + public processRawKeybindingText(keybindingStr: string): string { + return keybindingStr + .replace(/Enter/g, '↵') // ⏎ + .replace(/Backspace/g, '⌫'); + } // private _notifyError = (e: Parameters[0]) => { // const details = errorDetails(e.fullError) @@ -2255,12 +2259,6 @@ registerSingleton(IEditCodeService, EditCodeService, InstantiationType.Eager); -const processRawKeybindingText = (keybindingStr: string) => { - return keybindingStr - .replace(/Enter/g, '↵') // ⏎ - .replace(/Backspace/g, '⌫') -} - class AcceptRejectInlineWidget extends Widget implements IOverlayWidget { public getId(): string { @@ -2288,7 +2286,8 @@ class AcceptRejectInlineWidget extends Widget implements IOverlayWidget { offsetLines: number }, @IVoidCommandBarService private readonly _voidCommandBarService: IVoidCommandBarService, - @IKeybindingService private readonly _keybindingService: IKeybindingService + @IKeybindingService private readonly _keybindingService: IKeybindingService, + @IEditCodeService private readonly _editCodeService: IEditCodeService, ) { super(); @@ -2312,8 +2311,10 @@ class AcceptRejectInlineWidget extends Widget implements IOverlayWidget { const acceptKeybinding = this._keybindingService.lookupKeybinding(VOID_ACCEPT_DIFF_ACTION_ID); const rejectKeybinding = this._keybindingService.lookupKeybinding(VOID_REJECT_DIFF_ACTION_ID); - const acceptKeybindLabel = processRawKeybindingText(acceptKeybinding && acceptKeybinding.getLabel() || ''); - const rejectKeybindLabel = processRawKeybindingText(rejectKeybinding && rejectKeybinding.getLabel() || '') + // Use the standalone function directly since we're in a nested class that + // can't access EditCodeService's methods + const acceptKeybindLabel = this._editCodeService.processRawKeybindingText(acceptKeybinding && acceptKeybinding.getLabel() || ''); + const rejectKeybindLabel = this._editCodeService.processRawKeybindingText(rejectKeybinding && rejectKeybinding.getLabel() || ''); const commandBarStateAtUri = this._voidCommandBarService.stateOfURI[uri.fsPath]; const selectedDiffIdx = commandBarStateAtUri?.diffIdx ?? 0; // 0th item is selected by default diff --git a/src/vs/workbench/contrib/void/browser/editCodeServiceInterface.ts b/src/vs/workbench/contrib/void/browser/editCodeServiceInterface.ts index 4d7fafd6..f0712349 100644 --- a/src/vs/workbench/contrib/void/browser/editCodeServiceInterface.ts +++ b/src/vs/workbench/contrib/void/browser/editCodeServiceInterface.ts @@ -42,6 +42,8 @@ export const IEditCodeService = createDecorator('editCodeServi export interface IEditCodeService { readonly _serviceBrand: undefined; + processRawKeybindingText(keybindingStr: string): string; + callBeforeStartApplying(opts: CallBeforeStartApplyingOpts): Promise; startApplying(opts: StartApplyingOpts): [URI, Promise] | null; instantlyApplySearchReplaceBlocks(opts: { uri: URI; searchReplaceBlocks: string }): void; diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-editor-widgets-tsx/VoidCommandBar.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-editor-widgets-tsx/VoidCommandBar.tsx index a890a081..5604749e 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-editor-widgets-tsx/VoidCommandBar.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-editor-widgets-tsx/VoidCommandBar.tsx @@ -12,6 +12,16 @@ import { ScrollType } from '../../../../../../../editor/common/editorCommon.js'; import { acceptAllBg, acceptBorder, buttonFontSize, buttonTextColor, rejectAllBg, rejectBg, rejectBorder } from '../../../../common/helpers/colors.js'; import { VoidCommandBarProps } from '../../../voidCommandBarService.js'; import { Check, EllipsisVertical, Menu, MoveDown, MoveLeft, MoveRight, MoveUp, X } from 'lucide-react'; +import { + VOID_GOTO_NEXT_DIFF_ACTION_ID, + VOID_GOTO_PREV_DIFF_ACTION_ID, + VOID_GOTO_NEXT_URI_ACTION_ID, + VOID_GOTO_PREV_URI_ACTION_ID, + VOID_ACCEPT_FILE_ACTION_ID, + VOID_REJECT_FILE_ACTION_ID, + VOID_ACCEPT_ALL_DIFFS_ACTION_ID, + VOID_REJECT_ALL_DIFFS_ACTION_ID +} from '../../../actionIDs.js'; export const VoidCommandBarMain = ({ uri, editor }: VoidCommandBarProps) => { const isDark = useIsDark() @@ -86,6 +96,7 @@ export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { const commandService = accessor.get('ICommandService') const commandBarService = accessor.get('IVoidCommandBarService') const voidModelService = accessor.get('IVoidModelService') + const keybindingService = accessor.get('IKeybindingService') const { stateOfURI: commandBarState, sortedURIs: sortedCommandBarURIs } = useCommandBarState() const [showAcceptRejectAllButtons, setShowAcceptRejectAllButtons] = useState(false) @@ -163,6 +174,27 @@ export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { setShowAcceptRejectAllButtons(false); } + + + const _upKeybinding = keybindingService.lookupKeybinding(VOID_GOTO_PREV_DIFF_ACTION_ID); + const _downKeybinding = keybindingService.lookupKeybinding(VOID_GOTO_NEXT_DIFF_ACTION_ID); + const _leftKeybinding = keybindingService.lookupKeybinding(VOID_GOTO_PREV_URI_ACTION_ID); + const _rightKeybinding = keybindingService.lookupKeybinding(VOID_GOTO_NEXT_URI_ACTION_ID); + const _acceptFileKeybinding = keybindingService.lookupKeybinding(VOID_ACCEPT_FILE_ACTION_ID); + const _rejectFileKeybinding = keybindingService.lookupKeybinding(VOID_REJECT_FILE_ACTION_ID); + const _acceptAllKeybinding = keybindingService.lookupKeybinding(VOID_ACCEPT_ALL_DIFFS_ACTION_ID); + const _rejectAllKeybinding = keybindingService.lookupKeybinding(VOID_REJECT_ALL_DIFFS_ACTION_ID); + + const upKeybindLabel = editCodeService.processRawKeybindingText(_upKeybinding?.getLabel() || ''); + const downKeybindLabel = editCodeService.processRawKeybindingText(_downKeybinding?.getLabel() || ''); + const leftKeybindLabel = editCodeService.processRawKeybindingText(_leftKeybinding?.getLabel() || ''); + const rightKeybindLabel = editCodeService.processRawKeybindingText(_rightKeybinding?.getLabel() || ''); + const acceptFileKeybindLabel = editCodeService.processRawKeybindingText(_acceptFileKeybinding?.getLabel() || ''); + const rejectFileKeybindLabel = editCodeService.processRawKeybindingText(_rejectFileKeybinding?.getLabel() || ''); + const acceptAllKeybindLabel = editCodeService.processRawKeybindingText(_acceptAllKeybinding?.getLabel() || ''); + const rejectAllKeybindLabel = editCodeService.processRawKeybindingText(_rejectAllKeybinding?.getLabel() || ''); + + if (!isADiffZoneInAnyFile) return null return ( @@ -175,11 +207,11 @@ export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => {
@@ -201,7 +233,9 @@ export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { commandBarService.goToDiffIdx(prevDiffIdx); } }} - title="Previous diff" + data-tooltip-id="void-tooltip" + data-tooltip-content={`Previous diff ${upKeybindLabel ? `${upKeybindLabel}` : ''}`} + data-tooltip-delay-show={500} > @@ -224,7 +258,9 @@ export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { commandBarService.goToDiffIdx(nextDiffIdx); } }} - title="Next diff" + data-tooltip-id="void-tooltip" + data-tooltip-content={`Next diff ${downKeybindLabel ? `${downKeybindLabel}` : ''}`} + data-tooltip-delay-show={500} > @@ -244,7 +280,9 @@ export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { commandBarService.goToURIIdx(prevURIIdx); } }} - title="Previous file" + data-tooltip-id="void-tooltip" + data-tooltip-content={`Previous file ${leftKeybindLabel ? `${leftKeybindLabel}` : ''}`} + data-tooltip-delay-show={500} > @@ -264,7 +302,9 @@ export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { commandBarService.goToURIIdx(nextURIIdx); } }} - title="Next file" + data-tooltip-id="void-tooltip" + data-tooltip-content={`Next file ${rightKeybindLabel ? `${rightKeybindLabel}` : ''}`} + data-tooltip-delay-show={500} > @@ -275,11 +315,11 @@ export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { {showAcceptRejectAll && (