fix windows escaping (and broken tests) (#19011)

This commit is contained in:
Tommaso Sciortino
2026-02-13 14:19:08 -08:00
committed by GitHub
parent c7237f0c79
commit e7e4c68c5c
4 changed files with 16 additions and 14 deletions

View File

@@ -1023,7 +1023,7 @@ describe('useTextBuffer', () => {
useTextBuffer({ viewport, escapePastedPaths: true }),
);
act(() => result.current.insert(filePath, { paste: true }));
expect(getBufferState(result).text).toBe(`@${filePath} `);
expect(getBufferState(result).text).toBe(`@${escapePath(filePath)} `);
});
it('should not prepend @ to an invalid file path on insert', () => {
@@ -1042,7 +1042,7 @@ describe('useTextBuffer', () => {
);
const quotedPath = `'${filePath}'`;
act(() => result.current.insert(quotedPath, { paste: true }));
expect(getBufferState(result).text).toBe(`@${filePath} `);
expect(getBufferState(result).text).toBe(`@${escapePath(filePath)} `);
});
it('should not prepend @ to short text that is not a path', () => {
@@ -1063,9 +1063,11 @@ describe('useTextBuffer', () => {
const { result } = renderHook(() =>
useTextBuffer({ viewport, escapePastedPaths: true }),
);
const filePaths = `${file1} ${file2}`;
const filePaths = `${escapePath(file1)} ${escapePath(file2)}`;
act(() => result.current.insert(filePaths, { paste: true }));
expect(getBufferState(result).text).toBe(`@${file1} @${file2} `);
expect(getBufferState(result).text).toBe(
`@${escapePath(file1)} @${escapePath(file2)} `,
);
});
it('should handle multiple paths with escaped spaces', () => {
@@ -1077,13 +1079,12 @@ describe('useTextBuffer', () => {
const { result } = renderHook(() =>
useTextBuffer({ viewport, escapePastedPaths: true }),
);
// Construct escaped path string: "/path/to/my\ file.txt /path/to/other.txt"
const filePaths = `${escapePath(file1)} ${file2}`;
const filePaths = `${escapePath(file1)} ${escapePath(file2)}`;
act(() => result.current.insert(filePaths, { paste: true }));
expect(getBufferState(result).text).toBe(
`@${escapePath(file1)} @${file2} `,
`@${escapePath(file1)} @${escapePath(file2)} `,
);
});