mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Fix bugs breaking drag and drop of files. (#4887)
Co-authored-by: matt korwel <matt.korwel@gmail.com>
This commit is contained in:
@@ -407,8 +407,8 @@ describe('useTextBuffer', () => {
|
||||
useTextBuffer({ viewport, isValidPath: () => true }),
|
||||
);
|
||||
const filePath = '/path/to/a/valid/file.txt';
|
||||
act(() => result.current.insert(filePath));
|
||||
expect(getBufferState(result).text).toBe(`@${filePath}`);
|
||||
act(() => result.current.insert(filePath, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(`@${filePath} `);
|
||||
});
|
||||
|
||||
it('should not prepend @ to an invalid file path on insert', () => {
|
||||
@@ -416,7 +416,7 @@ describe('useTextBuffer', () => {
|
||||
useTextBuffer({ viewport, isValidPath: () => false }),
|
||||
);
|
||||
const notAPath = 'this is just some long text';
|
||||
act(() => result.current.insert(notAPath));
|
||||
act(() => result.current.insert(notAPath, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(notAPath);
|
||||
});
|
||||
|
||||
@@ -425,8 +425,8 @@ describe('useTextBuffer', () => {
|
||||
useTextBuffer({ viewport, isValidPath: () => true }),
|
||||
);
|
||||
const filePath = "'/path/to/a/valid/file.txt'";
|
||||
act(() => result.current.insert(filePath));
|
||||
expect(getBufferState(result).text).toBe(`@/path/to/a/valid/file.txt`);
|
||||
act(() => result.current.insert(filePath, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(`@/path/to/a/valid/file.txt `);
|
||||
});
|
||||
|
||||
it('should not prepend @ to short text that is not a path', () => {
|
||||
@@ -434,7 +434,7 @@ describe('useTextBuffer', () => {
|
||||
useTextBuffer({ viewport, isValidPath: () => true }),
|
||||
);
|
||||
const shortText = 'ab';
|
||||
act(() => result.current.insert(shortText));
|
||||
act(() => result.current.insert(shortText, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(shortText);
|
||||
});
|
||||
});
|
||||
@@ -449,7 +449,7 @@ describe('useTextBuffer', () => {
|
||||
}),
|
||||
);
|
||||
const filePath = '/path/to/a/valid/file.txt';
|
||||
act(() => result.current.insert(filePath));
|
||||
act(() => result.current.insert(filePath, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(filePath); // No @ prefix
|
||||
});
|
||||
|
||||
@@ -462,7 +462,7 @@ describe('useTextBuffer', () => {
|
||||
}),
|
||||
);
|
||||
const quotedFilePath = "'/path/to/a/valid/file.txt'";
|
||||
act(() => result.current.insert(quotedFilePath));
|
||||
act(() => result.current.insert(quotedFilePath, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(quotedFilePath); // No @ prefix, keeps quotes
|
||||
});
|
||||
|
||||
@@ -475,7 +475,7 @@ describe('useTextBuffer', () => {
|
||||
}),
|
||||
);
|
||||
const notAPath = 'this is just some text';
|
||||
act(() => result.current.insert(notAPath));
|
||||
act(() => result.current.insert(notAPath, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(notAPath);
|
||||
});
|
||||
|
||||
@@ -488,7 +488,7 @@ describe('useTextBuffer', () => {
|
||||
}),
|
||||
);
|
||||
const shortText = 'ls';
|
||||
act(() => result.current.insert(shortText));
|
||||
act(() => result.current.insert(shortText, { paste: true }));
|
||||
expect(getBufferState(result).text).toBe(shortText); // No @ prefix for short text
|
||||
});
|
||||
});
|
||||
@@ -849,6 +849,7 @@ describe('useTextBuffer', () => {
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
shift: false,
|
||||
paste: false,
|
||||
sequence: '\x7f',
|
||||
});
|
||||
result.current.handleInput({
|
||||
@@ -856,6 +857,7 @@ describe('useTextBuffer', () => {
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
shift: false,
|
||||
paste: false,
|
||||
sequence: '\x7f',
|
||||
});
|
||||
result.current.handleInput({
|
||||
@@ -863,6 +865,7 @@ describe('useTextBuffer', () => {
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
shift: false,
|
||||
paste: false,
|
||||
sequence: '\x7f',
|
||||
});
|
||||
});
|
||||
@@ -990,9 +993,9 @@ Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots
|
||||
|
||||
// Simulate pasting the long text multiple times
|
||||
act(() => {
|
||||
result.current.insert(longText);
|
||||
result.current.insert(longText);
|
||||
result.current.insert(longText);
|
||||
result.current.insert(longText, { paste: true });
|
||||
result.current.insert(longText, { paste: true });
|
||||
result.current.insert(longText, { paste: true });
|
||||
});
|
||||
|
||||
const state = getBufferState(result);
|
||||
|
||||
Reference in New Issue
Block a user