mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Only enable IDE integration if gemini-cli is running in the same path as open workspace (#5068)
This commit is contained in:
@@ -8,14 +8,35 @@ import * as vscode from 'vscode';
|
||||
import { IDEServer } from './ide-server';
|
||||
import { createLogger } from './utils/logger';
|
||||
|
||||
const IDE_WORKSPACE_PATH_ENV_VAR = 'GEMINI_CLI_IDE_WORKSPACE_PATH';
|
||||
|
||||
let ideServer: IDEServer;
|
||||
let logger: vscode.OutputChannel;
|
||||
let log: (message: string) => void = () => {};
|
||||
|
||||
function updateWorkspacePath(context: vscode.ExtensionContext) {
|
||||
const workspaceFolders = vscode.workspace.workspaceFolders;
|
||||
if (workspaceFolders && workspaceFolders.length === 1) {
|
||||
const workspaceFolder = workspaceFolders[0];
|
||||
context.environmentVariableCollection.replace(
|
||||
IDE_WORKSPACE_PATH_ENV_VAR,
|
||||
workspaceFolder.uri.fsPath,
|
||||
);
|
||||
} else {
|
||||
context.environmentVariableCollection.replace(
|
||||
IDE_WORKSPACE_PATH_ENV_VAR,
|
||||
'',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
logger = vscode.window.createOutputChannel('Gemini CLI IDE Companion');
|
||||
log = createLogger(context, logger);
|
||||
log('Extension activated');
|
||||
|
||||
updateWorkspacePath(context);
|
||||
|
||||
ideServer = new IDEServer(log);
|
||||
try {
|
||||
await ideServer.start(context);
|
||||
@@ -25,6 +46,9 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.workspace.onDidChangeWorkspaceFolders(() => {
|
||||
updateWorkspacePath(context);
|
||||
}),
|
||||
vscode.commands.registerCommand('gemini-cli.runGeminiCLI', () => {
|
||||
const geminiCmd = 'gemini';
|
||||
const terminal = vscode.window.createTerminal(`Gemini CLI`);
|
||||
|
||||
Reference in New Issue
Block a user