From 0ec0c324b100de48fb36084eba241ee3aeb2c84d Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Fri, 31 Jan 2025 20:17:51 -0800 Subject: [PATCH] void settings opening behavior --- .../src/void-settings-tsx/ModelDropdown.tsx | 3 +-- .../contrib/void/browser/voidSettingsPane.ts | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) 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 bef7f449..bbc6d9d1 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 @@ -40,9 +40,8 @@ const ModelSelectBox = ({ options, featureName }: { options: ModelOption[], feat getOptionDisplayName={(option) => option.selection.modelName} getOptionDropdownName={(option) => option.name} getOptionsEqual={(a, b) => optionsEqual([a], [b])} - className={`text-xs text-void-fg-3 px-1`} + className='text-xs text-void-fg-3 px-1' matchInputWidth={false} - // isMenuPositionFixed={featureName === 'Ctrl+K' ? false : true} /> } // const ModelSelectBox = ({ options, featureName }: { options: ModelOption[], featureName: FeatureName }) => { diff --git a/src/vs/workbench/contrib/void/browser/voidSettingsPane.ts b/src/vs/workbench/contrib/void/browser/voidSettingsPane.ts index c69596eb..e0feaf16 100644 --- a/src/vs/workbench/contrib/void/browser/voidSettingsPane.ts +++ b/src/vs/workbench/contrib/void/browser/voidSettingsPane.ts @@ -8,7 +8,7 @@ import { EditorInput } from '../../../common/editor/editorInput.js'; import * as nls from '../../../../nls.js'; import { EditorExtensions } from '../../../common/editor.js'; import { EditorPane } from '../../../browser/parts/editor/editorPane.js'; -import { IEditorGroup } from '../../../services/editor/common/editorGroupsService.js'; +import { IEditorGroup, IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js'; import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js'; import { IThemeService } from '../../../../platform/theme/common/themeService.js'; import { IStorageService } from '../../../../platform/storage/common/storage.js'; @@ -141,18 +141,27 @@ registerAction2(class extends Action2 { async run(accessor: ServicesAccessor): Promise { const editorService = accessor.get(IEditorService); + const editorGroupService = accessor.get(IEditorGroupsService); + const instantiationService = accessor.get(IInstantiationService); - // close all instances if found - const openEditors = editorService.findEditors(VoidSettingsInput.RESOURCE); - if (openEditors.length > 0) { - await editorService.closeEditors(openEditors); + // if is open, close it + const openEditors = editorService.findEditors(VoidSettingsInput.RESOURCE); // should only have 0 or 1 elements... + if (openEditors.length !== 0) { + const openEditor = openEditors[0].editor + const isCurrentlyOpen = editorService.activeEditor?.resource?.fsPath === openEditor.resource?.fsPath + if (isCurrentlyOpen) + await editorService.closeEditors(openEditors) + else + await editorGroupService.activeGroup.openEditor(openEditor) return; } + // else open it const input = instantiationService.createInstance(VoidSettingsInput); - await editorService.openEditor(input); + + await editorGroupService.activeGroup.openEditor(input); } })