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 8226db82..591886bc 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 @@ -297,8 +297,6 @@ export const SidebarChat = () => { const isDisabled = !instructions.trim() const [formHeight, setFormHeight] = useState(0) const [sidebarHeight, setSidebarHeight] = useState(0) - const formRef = useCallback((node: HTMLFormElement | null) => { if (node) { setFormHeight(node.clientHeight); } }, [setFormHeight]); - const sidebarRef = useCallback((node: HTMLDivElement | null) => { if (node) { setSidebarHeight(node.clientHeight); } }, [setSidebarHeight]); const onChangeText = useCallback((newStr: string) => { setInstructions(newStr) }, [setInstructions]) @@ -406,8 +404,14 @@ export const SidebarChat = () => { const previousMessages = currentThread?.messages ?? [] + + + + const [_test, _setTest] = useState([]) + + return
{ if (ref) { setSidebarHeight(ref.clientHeight); } }} className={`w-full h-full`} > { {/* message stream */} -
{`text`}
+ + {_test.map((_, i) =>
div {i}
)} +
{`totalHeight: ${sidebarHeight - formHeight - 30}`}
+
{`sidebarHeight: ${sidebarHeight}`}
+
{`formHeight: ${formHeight}`}
@@ -430,7 +438,7 @@ export const SidebarChat = () => { className={`right-0 left-0 m-2 z-[999] ${previousMessages.length > 0 ? 'absolute bottom-0' : ''}`} >
{ if (ref) { setFormHeight(ref.clientHeight); } }} className={` flex flex-col gap-2 p-2 relative input text-left shrink-0 transition-all duration-200 diff --git a/src/vs/workbench/contrib/void/browser/sidebarActions.ts b/src/vs/workbench/contrib/void/browser/sidebarActions.ts index bc80596d..06f86b8e 100644 --- a/src/vs/workbench/contrib/void/browser/sidebarActions.ts +++ b/src/vs/workbench/contrib/void/browser/sidebarActions.ts @@ -73,20 +73,12 @@ registerAction2(class extends Action2 { accessor.get(IEditorService).activeTextEditorControl?.getSelection() ) - // add selection - const threadHistoryService = accessor.get(IThreadHistoryService) - const currentStaging = threadHistoryService.state._currentStagingSelections - const currentStagingEltIdx = currentStaging?.findIndex(s => - s.fileURI.fsPath === model.uri.fsPath - && s.range?.startLineNumber === selectionRange?.startLineNumber - && s.range?.endLineNumber === selectionRange?.endLineNumber - ) if (selectionRange) { const selectionStr = getContentInRange(model, selectionRange) - const selection: CodeStagingSelection = selectionStr === null ? { + const selection: CodeStagingSelection = selectionStr === null || selectionRange.startLineNumber > selectionRange.endLineNumber ? { type: 'File', fileURI: model.uri, selectionStr: null, @@ -98,7 +90,16 @@ registerAction2(class extends Action2 { range: selectionRange, } - // overwrite selections that match with this one (compares by `fileURI` and line numbers in `range`) + // add selection to staging + const threadHistoryService = accessor.get(IThreadHistoryService) + const currentStaging = threadHistoryService.state._currentStagingSelections + const currentStagingEltIdx = currentStaging?.findIndex(s => + s.fileURI.fsPath === model.uri.fsPath + && s.range?.startLineNumber === selection.range?.startLineNumber + && s.range?.endLineNumber === selection.range?.endLineNumber + ) + + // if matches with existing selection, overwrite if (currentStagingEltIdx !== undefined && currentStagingEltIdx !== -1) { threadHistoryService.setStaging([ ...currentStaging!.slice(0, currentStagingEltIdx), @@ -106,6 +107,7 @@ registerAction2(class extends Action2 { ...currentStaging!.slice(currentStagingEltIdx + 1, Infinity) ]) } + // if no match, add else { threadHistoryService.setStaging([...(currentStaging ?? []), selection]) }