mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 19:52:02 +00:00
Auto insert @ when dragging and dropping files. (#812)
This commit is contained in:
parent
18d6a11c04
commit
ab44824e07
3 changed files with 213 additions and 29 deletions
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { Text, Box, useInput, useStdin } from 'ink';
|
||||
import { Colors } from '../colors.js';
|
||||
|
|
@ -58,11 +59,20 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||
|
||||
const { stdin, setRawMode } = useStdin();
|
||||
|
||||
const isValidPath = useCallback((filePath: string): boolean => {
|
||||
try {
|
||||
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
}, []);
|
||||
|
||||
const buffer = useTextBuffer({
|
||||
initialText: '',
|
||||
viewport: { height, width: effectiveWidth },
|
||||
stdin,
|
||||
setRawMode,
|
||||
isValidPath,
|
||||
});
|
||||
|
||||
const completion = useCompletion(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue