mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 11:04:42 -07:00
refactor(core): extract ToolModificationHandler from scheduler (#16118)
This commit is contained in:
@@ -311,11 +311,18 @@ describe('editor utils', () => {
|
||||
});
|
||||
}
|
||||
|
||||
it('should return the correct command for emacs', () => {
|
||||
const command = getDiffCommand('old.txt', 'new.txt', 'emacs');
|
||||
it('should return the correct command for emacs with escaped paths', () => {
|
||||
const command = getDiffCommand(
|
||||
'old file "quote".txt',
|
||||
'new file \\back\\slash.txt',
|
||||
'emacs',
|
||||
);
|
||||
expect(command).toEqual({
|
||||
command: 'emacs',
|
||||
args: ['--eval', '(ediff "old.txt" "new.txt")'],
|
||||
args: [
|
||||
'--eval',
|
||||
'(ediff "old file \\"quote\\".txt" "new file \\\\back\\\\slash.txt")',
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -60,6 +60,14 @@ function isValidEditorType(editor: string): editor is EditorType {
|
||||
return EDITORS_SET.has(editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a string for use in an Emacs Lisp string literal.
|
||||
* Wraps in double quotes and escapes backslashes and double quotes.
|
||||
*/
|
||||
function escapeELispString(str: string): string {
|
||||
return `"${str.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
||||
}
|
||||
|
||||
interface DiffCommand {
|
||||
command: string;
|
||||
args: string[];
|
||||
@@ -182,7 +190,10 @@ export function getDiffCommand(
|
||||
case 'emacs':
|
||||
return {
|
||||
command: 'emacs',
|
||||
args: ['--eval', `(ediff "${oldPath}" "${newPath}")`],
|
||||
args: [
|
||||
'--eval',
|
||||
`(ediff ${escapeELispString(oldPath)} ${escapeELispString(newPath)})`,
|
||||
],
|
||||
};
|
||||
case 'hx':
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user