mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 23:14:32 -07:00
Fix newline insertion bug in replace tool (#18595)
This commit is contained in:
@@ -167,7 +167,7 @@ async function calculateFlexibleReplacement(
|
||||
if (isMatch) {
|
||||
flexibleOccurrences++;
|
||||
const firstLineInMatch = window[0];
|
||||
const indentationMatch = firstLineInMatch.match(/^(\s*)/);
|
||||
const indentationMatch = firstLineInMatch.match(/^([ \t]*)/);
|
||||
const indentation = indentationMatch ? indentationMatch[1] : '';
|
||||
const newBlockWithIndent = replaceLines.map(
|
||||
(line: string) => `${indentation}${line}`,
|
||||
@@ -229,7 +229,7 @@ async function calculateRegexReplacement(
|
||||
|
||||
// The final pattern captures leading whitespace (indentation) and then matches the token pattern.
|
||||
// 'm' flag enables multi-line mode, so '^' matches the start of any line.
|
||||
const finalPattern = `^(\\s*)${pattern}`;
|
||||
const finalPattern = `^([ \t]*)${pattern}`;
|
||||
const flexibleRegex = new RegExp(finalPattern, 'm');
|
||||
|
||||
const match = flexibleRegex.exec(currentContent);
|
||||
|
||||
Reference in New Issue
Block a user