2025-06-12 02:21:54 +01:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
allowEditorTypeInSandbox,
|
2026-02-05 21:52:41 +01:00
|
|
|
hasValidEditorCommand,
|
2025-06-12 02:21:54 +01:00
|
|
|
type EditorType,
|
2025-11-18 12:01:16 -05:00
|
|
|
EDITOR_DISPLAY_NAMES,
|
2025-06-25 05:41:11 -07:00
|
|
|
} from '@google/gemini-cli-core';
|
2025-06-12 02:21:54 +01:00
|
|
|
|
|
|
|
|
export interface EditorDisplay {
|
|
|
|
|
name: string;
|
|
|
|
|
type: EditorType | 'not_set';
|
|
|
|
|
disabled: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class EditorSettingsManager {
|
|
|
|
|
private readonly availableEditors: EditorDisplay[];
|
|
|
|
|
|
|
|
|
|
constructor() {
|
2026-02-10 00:10:15 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
2025-08-01 10:40:05 -04:00
|
|
|
const editorTypes = Object.keys(
|
|
|
|
|
EDITOR_DISPLAY_NAMES,
|
|
|
|
|
).sort() as EditorType[];
|
2025-06-12 02:21:54 +01:00
|
|
|
this.availableEditors = [
|
|
|
|
|
{
|
|
|
|
|
name: 'None',
|
|
|
|
|
type: 'not_set',
|
|
|
|
|
disabled: false,
|
|
|
|
|
},
|
|
|
|
|
...editorTypes.map((type) => {
|
2026-02-05 21:52:41 +01:00
|
|
|
const hasEditor = hasValidEditorCommand(type);
|
2025-06-12 02:21:54 +01:00
|
|
|
const isAllowedInSandbox = allowEditorTypeInSandbox(type);
|
|
|
|
|
|
|
|
|
|
let labelSuffix = !isAllowedInSandbox
|
|
|
|
|
? ' (Not available in sandbox)'
|
|
|
|
|
: '';
|
|
|
|
|
labelSuffix = !hasEditor ? ' (Not installed)' : labelSuffix;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
name: EDITOR_DISPLAY_NAMES[type] + labelSuffix,
|
|
|
|
|
type,
|
|
|
|
|
disabled: !hasEditor || !isAllowedInSandbox,
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getAvailableEditorDisplays(): EditorDisplay[] {
|
|
|
|
|
return this.availableEditors;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const editorSettingsManager = new EditorSettingsManager();
|