mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 14:40:52 -07:00
refactor(core): robust trimPreservingTrailingNewline and regression test (#18196)
This commit is contained in:
@@ -665,6 +665,30 @@ describe('editCorrector', () => {
|
||||
expect(result.params.new_string).toBe('replaced\n\n');
|
||||
expect(result.occurrences).toBe(1);
|
||||
});
|
||||
|
||||
it('Test 7.2: should handle trailing newlines separated by spaces (regression fix)', async () => {
|
||||
const currentContent = 'find me '; // Matches old_string initially
|
||||
const originalParams = {
|
||||
file_path: '/test/file.txt',
|
||||
old_string: 'find me ', // Trailing space
|
||||
new_string: 'replaced \n \n', // Trailing newlines with spaces
|
||||
};
|
||||
|
||||
const result = await ensureCorrectEdit(
|
||||
'/test/file.txt',
|
||||
currentContent,
|
||||
originalParams,
|
||||
mockGeminiClientInstance,
|
||||
mockBaseLlmClientInstance,
|
||||
abortSignal,
|
||||
false,
|
||||
);
|
||||
|
||||
expect(result.params.old_string).toBe('find me');
|
||||
// Should capture both newlines and join them, stripping the space between
|
||||
expect(result.params.new_string).toBe('replaced\n\n');
|
||||
expect(result.occurrences).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user