refactor: push isValidPath() into parsePastedPaths() (#18664)

This commit is contained in:
Tommaso Sciortino
2026-02-09 13:19:51 -08:00
committed by GitHub
parent 9e41b2cd89
commit 1b98c1f806
15 changed files with 247 additions and 261 deletions
@@ -757,7 +757,7 @@ interface UseTextBufferProps {
stdin?: NodeJS.ReadStream | null; // For external editor
setRawMode?: (mode: boolean) => void; // For external editor
onChange?: (text: string) => void; // Callback for when text changes
isValidPath: (path: string) => boolean;
escapePastedPaths?: boolean;
shellModeActive?: boolean; // Whether the text buffer is in shell mode
inputFilter?: (text: string) => string; // Optional filter for input text
singleLine?: boolean;
@@ -2678,7 +2678,7 @@ export function useTextBuffer({
stdin,
setRawMode,
onChange,
isValidPath,
escapePastedPaths = false,
shellModeActive = false,
inputFilter,
singleLine = false,
@@ -2795,7 +2795,8 @@ export function useTextBuffer({
if (
ch.length >= minLengthToInferAsDragDrop &&
!shellModeActive &&
paste
paste &&
escapePastedPaths
) {
let potentialPath = ch.trim();
const quoteMatch = potentialPath.match(/^'(.*)'$/);
@@ -2805,7 +2806,7 @@ export function useTextBuffer({
potentialPath = potentialPath.trim();
const processed = parsePastedPaths(potentialPath, isValidPath);
const processed = parsePastedPaths(potentialPath);
if (processed) {
textToInsert = processed;
}
@@ -2827,7 +2828,7 @@ export function useTextBuffer({
dispatch({ type: 'insert', payload: currentText, isPaste: paste });
}
},
[isValidPath, shellModeActive],
[shellModeActive, escapePastedPaths],
);
const newline = useCallback((): void => {