Auto insert @ when dragging and dropping files. (#812)

This commit is contained in:
Jacob Richman 2025-06-07 14:48:56 -07:00 committed by GitHub
parent 18d6a11c04
commit ab44824e07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 213 additions and 29 deletions

View file

@ -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(