mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-10 10:00:53 -07:00
fix(windows): resolve interactive shell arrow-key navigation on Windows (#23505)
This commit is contained in:
@@ -488,7 +488,11 @@ describe('getShellConfiguration', () => {
|
||||
it('should return PowerShell configuration by default', () => {
|
||||
const config = getShellConfiguration();
|
||||
expect(config.executable).toBe('powershell.exe');
|
||||
expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']);
|
||||
expect(config.argsPrefix).toEqual([
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-Command',
|
||||
]);
|
||||
expect(config.shell).toBe('powershell');
|
||||
});
|
||||
|
||||
@@ -513,7 +517,11 @@ describe('getShellConfiguration', () => {
|
||||
vi.stubEnv('ComSpec', 'C:\\WINDOWS\\system32\\cmd.exe');
|
||||
const config = getShellConfiguration();
|
||||
expect(config.executable).toBe('powershell.exe');
|
||||
expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']);
|
||||
expect(config.argsPrefix).toEqual([
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-Command',
|
||||
]);
|
||||
expect(config.shell).toBe('powershell');
|
||||
});
|
||||
|
||||
@@ -523,7 +531,11 @@ describe('getShellConfiguration', () => {
|
||||
vi.stubEnv('ComSpec', psPath);
|
||||
const config = getShellConfiguration();
|
||||
expect(config.executable).toBe(psPath);
|
||||
expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']);
|
||||
expect(config.argsPrefix).toEqual([
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-Command',
|
||||
]);
|
||||
expect(config.shell).toBe('powershell');
|
||||
});
|
||||
|
||||
@@ -532,7 +544,11 @@ describe('getShellConfiguration', () => {
|
||||
vi.stubEnv('ComSpec', pwshPath);
|
||||
const config = getShellConfiguration();
|
||||
expect(config.executable).toBe(pwshPath);
|
||||
expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']);
|
||||
expect(config.argsPrefix).toEqual([
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-Command',
|
||||
]);
|
||||
expect(config.shell).toBe('powershell');
|
||||
});
|
||||
|
||||
@@ -540,7 +556,11 @@ describe('getShellConfiguration', () => {
|
||||
vi.stubEnv('ComSpec', 'C:\\Path\\To\\POWERSHELL.EXE');
|
||||
const config = getShellConfiguration();
|
||||
expect(config.executable).toBe('C:\\Path\\To\\POWERSHELL.EXE');
|
||||
expect(config.argsPrefix).toEqual(['-NoProfile', '-Command']);
|
||||
expect(config.argsPrefix).toEqual([
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-Command',
|
||||
]);
|
||||
expect(config.shell).toBe('powershell');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -691,6 +691,11 @@ export function parseCommandDetails(
|
||||
*/
|
||||
export function getShellConfiguration(): ShellConfiguration {
|
||||
if (isWindows()) {
|
||||
// -NonInteractive prevents PSReadLine from intercepting console input
|
||||
// events inside the ConPTY session, which otherwise causes interactive
|
||||
// TUI tools (e.g. pnpm create vite, vim) to receive malformed key events
|
||||
// and exit when arrow keys are pressed.
|
||||
const powershellArgsPrefix = ['-NoProfile', '-NonInteractive', '-Command'];
|
||||
const comSpec = process.env['ComSpec'];
|
||||
if (comSpec) {
|
||||
const executable = comSpec.toLowerCase();
|
||||
@@ -700,7 +705,7 @@ export function getShellConfiguration(): ShellConfiguration {
|
||||
) {
|
||||
return {
|
||||
executable: comSpec,
|
||||
argsPrefix: ['-NoProfile', '-Command'],
|
||||
argsPrefix: powershellArgsPrefix,
|
||||
shell: 'powershell',
|
||||
};
|
||||
}
|
||||
@@ -718,7 +723,7 @@ export function getShellConfiguration(): ShellConfiguration {
|
||||
// Fall back to Windows PowerShell 5.1 when pwsh.exe is not installed.
|
||||
return {
|
||||
executable: 'powershell.exe',
|
||||
argsPrefix: ['-NoProfile', '-Command'],
|
||||
argsPrefix: powershellArgsPrefix,
|
||||
shell: 'powershell',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user