feat: add VSCodium editor support (#2299)
Co-authored-by: Scott Densmore <scottdensmore@mac.com> Co-authored-by: Allen Hutchison <adh@google.com>
This commit is contained in:
parent
0d51e4b4b7
commit
3518ff7663
|
@ -19,6 +19,7 @@ export interface EditorDisplay {
|
||||||
export const EDITOR_DISPLAY_NAMES: Record<EditorType, string> = {
|
export const EDITOR_DISPLAY_NAMES: Record<EditorType, string> = {
|
||||||
zed: 'Zed',
|
zed: 'Zed',
|
||||||
vscode: 'VS Code',
|
vscode: 'VS Code',
|
||||||
|
vscodium: 'VSCodium',
|
||||||
windsurf: 'Windsurf',
|
windsurf: 'Windsurf',
|
||||||
cursor: 'Cursor',
|
cursor: 'Cursor',
|
||||||
vim: 'Vim',
|
vim: 'Vim',
|
||||||
|
@ -31,6 +32,7 @@ class EditorSettingsManager {
|
||||||
const editorTypes: EditorType[] = [
|
const editorTypes: EditorType[] = [
|
||||||
'zed',
|
'zed',
|
||||||
'vscode',
|
'vscode',
|
||||||
|
'vscodium',
|
||||||
'windsurf',
|
'windsurf',
|
||||||
'cursor',
|
'cursor',
|
||||||
'vim',
|
'vim',
|
||||||
|
|
|
@ -56,6 +56,7 @@ describe('editor utils', () => {
|
||||||
win32Command: string;
|
win32Command: string;
|
||||||
}> = [
|
}> = [
|
||||||
{ editor: 'vscode', command: 'code', win32Command: 'code.cmd' },
|
{ editor: 'vscode', command: 'code', win32Command: 'code.cmd' },
|
||||||
|
{ editor: 'vscodium', command: 'codium', win32Command: 'codium.cmd' },
|
||||||
{ editor: 'windsurf', command: 'windsurf', win32Command: 'windsurf' },
|
{ editor: 'windsurf', command: 'windsurf', win32Command: 'windsurf' },
|
||||||
{ editor: 'cursor', command: 'cursor', win32Command: 'cursor' },
|
{ editor: 'cursor', command: 'cursor', win32Command: 'cursor' },
|
||||||
{ editor: 'vim', command: 'vim', win32Command: 'vim' },
|
{ editor: 'vim', command: 'vim', win32Command: 'vim' },
|
||||||
|
@ -112,6 +113,7 @@ describe('editor utils', () => {
|
||||||
win32Command: string;
|
win32Command: string;
|
||||||
}> = [
|
}> = [
|
||||||
{ editor: 'vscode', command: 'code', win32Command: 'code.cmd' },
|
{ editor: 'vscode', command: 'code', win32Command: 'code.cmd' },
|
||||||
|
{ editor: 'vscodium', command: 'codium', win32Command: 'codium.cmd' },
|
||||||
{ editor: 'windsurf', command: 'windsurf', win32Command: 'windsurf' },
|
{ editor: 'windsurf', command: 'windsurf', win32Command: 'windsurf' },
|
||||||
{ editor: 'cursor', command: 'cursor', win32Command: 'cursor' },
|
{ editor: 'cursor', command: 'cursor', win32Command: 'cursor' },
|
||||||
{ editor: 'zed', command: 'zed', win32Command: 'zed' },
|
{ editor: 'zed', command: 'zed', win32Command: 'zed' },
|
||||||
|
@ -171,7 +173,13 @@ describe('editor utils', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('openDiff', () => {
|
describe('openDiff', () => {
|
||||||
const spawnEditors: EditorType[] = ['vscode', 'windsurf', 'cursor', 'zed'];
|
const spawnEditors: EditorType[] = [
|
||||||
|
'vscode',
|
||||||
|
'vscodium',
|
||||||
|
'windsurf',
|
||||||
|
'cursor',
|
||||||
|
'zed',
|
||||||
|
];
|
||||||
for (const editor of spawnEditors) {
|
for (const editor of spawnEditors) {
|
||||||
it(`should call spawn for ${editor}`, async () => {
|
it(`should call spawn for ${editor}`, async () => {
|
||||||
const mockSpawn = {
|
const mockSpawn = {
|
||||||
|
@ -285,7 +293,13 @@ describe('editor utils', () => {
|
||||||
expect(allowEditorTypeInSandbox('vim')).toBe(true);
|
expect(allowEditorTypeInSandbox('vim')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
const guiEditors: EditorType[] = ['vscode', 'windsurf', 'cursor', 'zed'];
|
const guiEditors: EditorType[] = [
|
||||||
|
'vscode',
|
||||||
|
'vscodium',
|
||||||
|
'windsurf',
|
||||||
|
'cursor',
|
||||||
|
'zed',
|
||||||
|
];
|
||||||
for (const editor of guiEditors) {
|
for (const editor of guiEditors) {
|
||||||
it(`should not allow ${editor} in sandbox mode`, () => {
|
it(`should not allow ${editor} in sandbox mode`, () => {
|
||||||
process.env.SANDBOX = 'sandbox';
|
process.env.SANDBOX = 'sandbox';
|
||||||
|
|
|
@ -6,10 +6,18 @@
|
||||||
|
|
||||||
import { execSync, spawn } from 'child_process';
|
import { execSync, spawn } from 'child_process';
|
||||||
|
|
||||||
export type EditorType = 'vscode' | 'windsurf' | 'cursor' | 'vim' | 'zed';
|
export type EditorType =
|
||||||
|
| 'vscode'
|
||||||
|
| 'vscodium'
|
||||||
|
| 'windsurf'
|
||||||
|
| 'cursor'
|
||||||
|
| 'vim'
|
||||||
|
| 'zed';
|
||||||
|
|
||||||
function isValidEditorType(editor: string): editor is EditorType {
|
function isValidEditorType(editor: string): editor is EditorType {
|
||||||
return ['vscode', 'windsurf', 'cursor', 'vim', 'zed'].includes(editor);
|
return ['vscode', 'vscodium', 'windsurf', 'cursor', 'vim', 'zed'].includes(
|
||||||
|
editor,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DiffCommand {
|
interface DiffCommand {
|
||||||
|
@ -31,6 +39,7 @@ function commandExists(cmd: string): boolean {
|
||||||
|
|
||||||
const editorCommands: Record<EditorType, { win32: string; default: string }> = {
|
const editorCommands: Record<EditorType, { win32: string; default: string }> = {
|
||||||
vscode: { win32: 'code.cmd', default: 'code' },
|
vscode: { win32: 'code.cmd', default: 'code' },
|
||||||
|
vscodium: { win32: 'codium.cmd', default: 'codium' },
|
||||||
windsurf: { win32: 'windsurf', default: 'windsurf' },
|
windsurf: { win32: 'windsurf', default: 'windsurf' },
|
||||||
cursor: { win32: 'cursor', default: 'cursor' },
|
cursor: { win32: 'cursor', default: 'cursor' },
|
||||||
vim: { win32: 'vim', default: 'vim' },
|
vim: { win32: 'vim', default: 'vim' },
|
||||||
|
@ -46,7 +55,7 @@ export function checkHasEditorType(editor: EditorType): boolean {
|
||||||
|
|
||||||
export function allowEditorTypeInSandbox(editor: EditorType): boolean {
|
export function allowEditorTypeInSandbox(editor: EditorType): boolean {
|
||||||
const notUsingSandbox = !process.env.SANDBOX;
|
const notUsingSandbox = !process.env.SANDBOX;
|
||||||
if (['vscode', 'windsurf', 'cursor', 'zed'].includes(editor)) {
|
if (['vscode', 'vscodium', 'windsurf', 'cursor', 'zed'].includes(editor)) {
|
||||||
return notUsingSandbox;
|
return notUsingSandbox;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -82,6 +91,7 @@ export function getDiffCommand(
|
||||||
process.platform === 'win32' ? commandConfig.win32 : commandConfig.default;
|
process.platform === 'win32' ? commandConfig.win32 : commandConfig.default;
|
||||||
switch (editor) {
|
switch (editor) {
|
||||||
case 'vscode':
|
case 'vscode':
|
||||||
|
case 'vscodium':
|
||||||
case 'windsurf':
|
case 'windsurf':
|
||||||
case 'cursor':
|
case 'cursor':
|
||||||
case 'zed':
|
case 'zed':
|
||||||
|
@ -138,6 +148,7 @@ export async function openDiff(
|
||||||
try {
|
try {
|
||||||
switch (editor) {
|
switch (editor) {
|
||||||
case 'vscode':
|
case 'vscode':
|
||||||
|
case 'vscodium':
|
||||||
case 'windsurf':
|
case 'windsurf':
|
||||||
case 'cursor':
|
case 'cursor':
|
||||||
case 'zed':
|
case 'zed':
|
||||||
|
|
Loading…
Reference in New Issue