feat: tab completions for file paths (#279)
Made a PR as was requested in the #113
This commit is contained in:
@@ -44,6 +44,11 @@ export type TextInputProps = {
|
||||
* Function to call when `Enter` is pressed, where first argument is a value of the input.
|
||||
*/
|
||||
readonly onSubmit?: (value: string) => void;
|
||||
|
||||
/**
|
||||
* Explicitly set the cursor position to the end of the text
|
||||
*/
|
||||
readonly cursorToEnd?: boolean;
|
||||
};
|
||||
|
||||
function findPrevWordJump(prompt: string, cursorOffset: number) {
|
||||
@@ -90,12 +95,22 @@ function TextInput({
|
||||
showCursor = true,
|
||||
onChange,
|
||||
onSubmit,
|
||||
cursorToEnd = false,
|
||||
}: TextInputProps) {
|
||||
const [state, setState] = useState({
|
||||
cursorOffset: (originalValue || "").length,
|
||||
cursorWidth: 0,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (cursorToEnd) {
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
cursorOffset: (originalValue || "").length,
|
||||
}));
|
||||
}
|
||||
}, [cursorToEnd, originalValue, focus]);
|
||||
|
||||
const { cursorOffset, cursorWidth } = state;
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user