mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
void settings opening behavior
This commit is contained in:
parent
9cd8295dab
commit
0ec0c324b1
2 changed files with 16 additions and 8 deletions
|
|
@ -40,9 +40,8 @@ const ModelSelectBox = ({ options, featureName }: { options: ModelOption[], feat
|
||||||
getOptionDisplayName={(option) => option.selection.modelName}
|
getOptionDisplayName={(option) => option.selection.modelName}
|
||||||
getOptionDropdownName={(option) => option.name}
|
getOptionDropdownName={(option) => option.name}
|
||||||
getOptionsEqual={(a, b) => optionsEqual([a], [b])}
|
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}
|
matchInputWidth={false}
|
||||||
// isMenuPositionFixed={featureName === 'Ctrl+K' ? false : true}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
// const ModelSelectBox = ({ options, featureName }: { options: ModelOption[], featureName: FeatureName }) => {
|
// const ModelSelectBox = ({ options, featureName }: { options: ModelOption[], featureName: FeatureName }) => {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { EditorInput } from '../../../common/editor/editorInput.js';
|
||||||
import * as nls from '../../../../nls.js';
|
import * as nls from '../../../../nls.js';
|
||||||
import { EditorExtensions } from '../../../common/editor.js';
|
import { EditorExtensions } from '../../../common/editor.js';
|
||||||
import { EditorPane } from '../../../browser/parts/editor/editorPane.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 { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js';
|
||||||
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
|
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
|
||||||
import { IStorageService } from '../../../../platform/storage/common/storage.js';
|
import { IStorageService } from '../../../../platform/storage/common/storage.js';
|
||||||
|
|
@ -141,18 +141,27 @@ registerAction2(class extends Action2 {
|
||||||
|
|
||||||
async run(accessor: ServicesAccessor): Promise<void> {
|
async run(accessor: ServicesAccessor): Promise<void> {
|
||||||
const editorService = accessor.get(IEditorService);
|
const editorService = accessor.get(IEditorService);
|
||||||
|
const editorGroupService = accessor.get(IEditorGroupsService);
|
||||||
|
|
||||||
const instantiationService = accessor.get(IInstantiationService);
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
|
|
||||||
// close all instances if found
|
// if is open, close it
|
||||||
const openEditors = editorService.findEditors(VoidSettingsInput.RESOURCE);
|
const openEditors = editorService.findEditors(VoidSettingsInput.RESOURCE); // should only have 0 or 1 elements...
|
||||||
if (openEditors.length > 0) {
|
if (openEditors.length !== 0) {
|
||||||
await editorService.closeEditors(openEditors);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// else open it
|
// else open it
|
||||||
const input = instantiationService.createInstance(VoidSettingsInput);
|
const input = instantiationService.createInstance(VoidSettingsInput);
|
||||||
await editorService.openEditor(input);
|
|
||||||
|
await editorGroupService.activeGroup.openEditor(input);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue