mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-05 10:51:12 -07:00
fix: expand paste placeholders in TextInput on submit (#19946)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -38,6 +38,17 @@ export const LARGE_PASTE_CHAR_THRESHOLD = 500;
|
||||
export const PASTED_TEXT_PLACEHOLDER_REGEX =
|
||||
/\[Pasted Text: \d+ (?:lines|chars)(?: #\d+)?\]/g;
|
||||
|
||||
// Replace paste placeholder strings with their actual pasted content.
|
||||
export function expandPastePlaceholders(
|
||||
text: string,
|
||||
pastedContent: Record<string, string>,
|
||||
): string {
|
||||
return text.replace(
|
||||
PASTED_TEXT_PLACEHOLDER_REGEX,
|
||||
(match) => pastedContent[match] || match,
|
||||
);
|
||||
}
|
||||
|
||||
export type Direction =
|
||||
| 'left'
|
||||
| 'right'
|
||||
@@ -3086,10 +3097,7 @@ export function useTextBuffer({
|
||||
const tmpDir = fs.mkdtempSync(pathMod.join(os.tmpdir(), 'gemini-edit-'));
|
||||
const filePath = pathMod.join(tmpDir, 'buffer.txt');
|
||||
// Expand paste placeholders so user sees full content in editor
|
||||
const expandedText = text.replace(
|
||||
PASTED_TEXT_PLACEHOLDER_REGEX,
|
||||
(match) => pastedContent[match] || match,
|
||||
);
|
||||
const expandedText = expandPastePlaceholders(text, pastedContent);
|
||||
fs.writeFileSync(filePath, expandedText, 'utf8');
|
||||
|
||||
dispatch({ type: 'create_undo_snapshot' });
|
||||
|
||||
Reference in New Issue
Block a user