mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-30 07:51:07 -07:00
feat(cli): add experimental.useOSC52Copy setting (#19488)
This commit is contained in:
committed by
GitHub
parent
ba3e327ba1
commit
09b623fbd7
@@ -14,6 +14,7 @@ import {
|
||||
copyToClipboard,
|
||||
getUrlOpenCommand,
|
||||
} from './commandUtils.js';
|
||||
import type { Settings } from '../../config/settingsSchema.js';
|
||||
|
||||
// Constants used by OSC-52 tests
|
||||
const ESC = '\u001B';
|
||||
@@ -257,6 +258,29 @@ describe('commandUtils', () => {
|
||||
expect(mockClipboardyWrite).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('uses OSC-52 when useOSC52Copy setting is enabled', async () => {
|
||||
const testText = 'forced-osc52';
|
||||
const tty = makeWritable({ isTTY: true });
|
||||
mockFs.createWriteStream.mockImplementation(() => {
|
||||
setTimeout(() => tty.emit('open'), 0);
|
||||
return tty;
|
||||
});
|
||||
|
||||
// NO environment signals for SSH/WSL/etc.
|
||||
const settings = {
|
||||
experimental: { useOSC52Copy: true },
|
||||
} as unknown as Settings;
|
||||
|
||||
await copyToClipboard(testText, settings);
|
||||
|
||||
const b64 = Buffer.from(testText, 'utf8').toString('base64');
|
||||
const expected = `${ESC}]52;c;${b64}${BEL}`;
|
||||
|
||||
expect(tty.write).toHaveBeenCalledTimes(1);
|
||||
expect(tty.write.mock.calls[0][0]).toBe(expected);
|
||||
expect(mockClipboardyWrite).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('wraps OSC-52 for tmux when in SSH', async () => {
|
||||
const testText = 'tmux-copy';
|
||||
const tty = makeWritable({ isTTY: true });
|
||||
|
||||
Reference in New Issue
Block a user