mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 00:14:28 -07:00
Fix dollar sign replacement bug in file editing (#7703)
This commit is contained in:
@@ -46,11 +46,11 @@ import {
|
||||
type Mock,
|
||||
} from 'vitest';
|
||||
import {
|
||||
applyReplacement,
|
||||
SmartEditTool,
|
||||
type EditToolParams,
|
||||
calculateReplacement,
|
||||
} from './smart-edit.js';
|
||||
import { applyReplacement } from './edit.js';
|
||||
import { type FileDiff, ToolConfirmationOutcome } from './tools.js';
|
||||
import { ToolErrorType } from './tool-error.js';
|
||||
import path from 'node:path';
|
||||
@@ -169,6 +169,22 @@ describe('SmartEditTool', () => {
|
||||
'hello new world new',
|
||||
);
|
||||
});
|
||||
|
||||
it('should treat $ literally and not as replacement pattern', () => {
|
||||
const current = 'regex end is $ and more';
|
||||
const oldStr = 'regex end is $';
|
||||
const newStr = 'regex end is $ and correct';
|
||||
const result = applyReplacement(current, oldStr, newStr, false);
|
||||
expect(result).toBe('regex end is $ and correct and more');
|
||||
});
|
||||
|
||||
it("should treat $' literally and not as a replacement pattern", () => {
|
||||
const current = 'foo';
|
||||
const oldStr = 'foo';
|
||||
const newStr = "bar$'baz";
|
||||
const result = applyReplacement(current, oldStr, newStr, false);
|
||||
expect(result).toBe("bar$'baz");
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateReplacement', () => {
|
||||
|
||||
Reference in New Issue
Block a user