diff options
author | Nate Sesti <33237525+sestinj@users.noreply.github.com> | 2023-07-11 15:14:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-11 15:14:53 -0700 |
commit | 125a4980f3b9e2b27ca10c75f5914cd0559ff828 (patch) | |
tree | 78895c399d3357c91b1975398e067e0c7fe9f2f5 /extension/react-app/src/components | |
parent | 3dc307bc9add75fba1f66c51218f0c32637e21fe (diff) | |
parent | 64e9877d2929f36aa2af94708620d3f2247ebebb (diff) | |
download | sncontinue-125a4980f3b9e2b27ca10c75f5914cd0559ff828.tar.gz sncontinue-125a4980f3b9e2b27ca10c75f5914cd0559ff828.tar.bz2 sncontinue-125a4980f3b9e2b27ca10c75f5914cd0559ff828.zip |
Merge pull request #237 from continuedev/bug-squashing
Bug squashing
Diffstat (limited to 'extension/react-app/src/components')
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 801c3a03..ac994b0a 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -180,6 +180,26 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { useImperativeHandle(ref, () => downshiftProps, [downshiftProps]); + const [metaKeyPressed, setMetaKeyPressed] = useState(false); + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === "Meta") { + setMetaKeyPressed(true); + } + }; + const handleKeyUp = (e: KeyboardEvent) => { + if (e.key === "Meta") { + setMetaKeyPressed(false); + } + }; + window.addEventListener("keydown", handleKeyDown); + window.addEventListener("keyup", handleKeyUp); + return () => { + window.removeEventListener("keydown", handleKeyDown); + window.removeEventListener("keyup", handleKeyUp); + }; + }); + useEffect(() => { if (!inputRef.current) { return; @@ -272,7 +292,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { <div className="flex px-2" ref={divRef} hidden={!downshiftProps.isOpen}> <MainTextInput disabled={props.disabled} - placeholder="Ask a question, give instructions, or type '/' to see slash commands" + placeholder="Ask a question, give instructions, or type '/' to see slash commands. ⌘⏎ to edit." {...getInputProps({ onChange: (e) => { const target = e.target as HTMLTextAreaElement; @@ -357,10 +377,13 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { ))} </Ul> </div> - {/* <span className="text-trueGray-400 ml-auto m-auto text-xs text-right"> - Highlight code to include as context. Currently open file included by - default. {highlightedCodeSections.length === 0 && ""} - </span> */} + {highlightedCodeSections.length === 0 && + (downshiftProps.inputValue?.startsWith("/edit") || + (metaKeyPressed && downshiftProps.inputValue?.length > 0)) && ( + <div className="text-trueGray-400 pr-4 text-xs text-right"> + Inserting at cursor + </div> + )} <ContextDropdown onMouseEnter={() => { setHoveringContextDropdown(true); |