mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat: External editor settings (#882)
This commit is contained in:
60
packages/cli/src/ui/editors/editorSettingsManager.ts
Normal file
60
packages/cli/src/ui/editors/editorSettingsManager.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import {
|
||||
allowEditorTypeInSandbox,
|
||||
checkHasEditorType,
|
||||
type EditorType,
|
||||
} from '@gemini-cli/core';
|
||||
|
||||
export interface EditorDisplay {
|
||||
name: string;
|
||||
type: EditorType | 'not_set';
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
export const EDITOR_DISPLAY_NAMES: Record<EditorType, string> = {
|
||||
vscode: 'VS Code',
|
||||
windsurf: 'Windsurf',
|
||||
cursor: 'Cursor',
|
||||
vim: 'Vim',
|
||||
};
|
||||
|
||||
class EditorSettingsManager {
|
||||
private readonly availableEditors: EditorDisplay[];
|
||||
|
||||
constructor() {
|
||||
const editorTypes: EditorType[] = ['vscode', 'windsurf', 'cursor', 'vim'];
|
||||
this.availableEditors = [
|
||||
{
|
||||
name: 'None',
|
||||
type: 'not_set',
|
||||
disabled: false,
|
||||
},
|
||||
...editorTypes.map((type) => {
|
||||
const hasEditor = checkHasEditorType(type);
|
||||
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();
|
||||
Reference in New Issue
Block a user