From dd133d2cd5eb131e02d095fb09c6fc9b81cdbe61 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 5 Jan 2025 21:27:16 -0800 Subject: [PATCH] ctrlK roundRange --- .../contrib/void/browser/quickEditActions.ts | 3 ++- .../react/src/quick-edit-tsx/QuickEditChat.tsx | 4 ++-- .../browser/react/src/sidebar-tsx/Sidebar.tsx | 2 +- .../void/browser/react/src/util/inputs.tsx | 8 ++++---- .../src/void-settings-tsx/ModelDropdown.tsx | 1 + .../contrib/void/browser/sidebarActions.ts | 16 +++++++++------- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/quickEditActions.ts b/src/vs/workbench/contrib/void/browser/quickEditActions.ts index 39461b18..285e21d2 100644 --- a/src/vs/workbench/contrib/void/browser/quickEditActions.ts +++ b/src/vs/workbench/contrib/void/browser/quickEditActions.ts @@ -11,6 +11,7 @@ import { IMetricsService } from '../../../../platform/void/common/metricsService import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js'; import { IInlineDiffsService } from './inlineDiffsService.js'; import { InputBox } from '../../../../base/browser/ui/inputbox/inputBox.js'; +import { roundRangeToLines } from './sidebarActions.js'; export type QuickEditPropsType = { @@ -54,7 +55,7 @@ registerAction2(class extends Action2 { if (!editor) return; const model = editor.getModel() if (!model) return; - const selection = editor.getSelection() + const selection = roundRangeToLines(editor.getSelection(), { emptySelectionBehavior: 'line' }) if (!selection) return; 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 6d66c5a3..26bbc9f9 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 @@ -146,9 +146,9 @@ export const QuickEditChat = ({ diffareaid, onGetInputBox, onUserUpdateText, onC
- + diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/Sidebar.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/Sidebar.tsx index b259a728..4a5f23b1 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/Sidebar.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/Sidebar.tsx @@ -39,7 +39,7 @@ export const Sidebar = ({ className }: { className: string }) => { sidebarStateService.setState({ currentTab: tabs[(index + 1) % tabs.length] as any }) }}>clickme {tab} */} -
+
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 6319c1f0..029e0000 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 @@ -197,11 +197,12 @@ export const VoidCheckBox = ({ label, value, onClick, className }: { label: stri } -export const VoidSelectBox = ({ onChangeSelection, onCreateInstance, selectBoxRef, options }: { +export const VoidSelectBox = ({ onChangeSelection, onCreateInstance, selectBoxRef, options, className }: { onChangeSelection: (value: T) => void; onCreateInstance?: ((instance: SelectBox) => void | IDisposable[]); selectBoxRef?: React.MutableRefObject; options: readonly { text: string, value: T }[]; + className?:string; }) => { const accessor = useAccessor() const contextViewProvider = accessor.get('IContextViewService') @@ -209,10 +210,9 @@ export const VoidSelectBox = ({ onChangeSelection, onCreateInstance, selectB let containerRef = useRef(null); return { containerRef.current = container diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/ModelDropdown.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/ModelDropdown.tsx index d0cd41b4..1a3bd734 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/ModelDropdown.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/ModelDropdown.tsx @@ -32,6 +32,7 @@ const ModelSelectBox = ({ options, featureName }: { options: ModelOption[], feat let weChangedText = false return { if (weChangedText) return diff --git a/src/vs/workbench/contrib/void/browser/sidebarActions.ts b/src/vs/workbench/contrib/void/browser/sidebarActions.ts index bd1c753f..b2a4df91 100644 --- a/src/vs/workbench/contrib/void/browser/sidebarActions.ts +++ b/src/vs/workbench/contrib/void/browser/sidebarActions.ts @@ -26,13 +26,17 @@ import { VOID_OPEN_SETTINGS_ACTION_ID } from './voidSettingsPane.js'; // ---------- Register commands and keybindings ---------- -const roundRangeToLines = (range: IRange | null | undefined) => { +export const roundRangeToLines = (range: IRange | null | undefined, options: { emptySelectionBehavior: 'null' | 'line' }) => { if (!range) return null // treat as no selection if selection is empty - if (range.endColumn === range.startColumn && range.endLineNumber === range.startLineNumber) - return null + if (range.endColumn === range.startColumn && range.endLineNumber === range.startLineNumber) { + if (options.emptySelectionBehavior === 'null') + return null + else if (options.emptySelectionBehavior === 'line') + return { startLineNumber: range.startLineNumber, startColumn: 1, endLineNumber: range.startLineNumber, endColumn: 1 } + } // IRange is 1-indexed const endLine = range.endColumn === 1 ? range.endLineNumber - 1 : range.endLineNumber // e.g. if the user triple clicks, it selects column=0, line=line -> column=0, line=line+1 @@ -77,10 +81,8 @@ registerAction2(class extends Action2 { stateService.fireFocusChat() const editor = editorService.getActiveCodeEditor() - const selectionRange = roundRangeToLines( - // accessor.get(IEditorService).activeTextEditorControl?.getSelection() - editor?.getSelection() - ) + // accessor.get(IEditorService).activeTextEditorControl?.getSelection() + const selectionRange = roundRangeToLines(editor?.getSelection(), { emptySelectionBehavior: 'null' }) // select whole lines