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 | 9adfb8bf5b9f44be82488e37bc32cbd9a8817b53 (patch) | |
| tree | 8399d02483267ec024034a923475bd6eaf397154 /extension/react-app/src | |
| parent | 3f9e7a1fa59c4f684aef544436062f8825d77b31 (diff) | |
| parent | 9846f4769ff33a346d76e26ad730d19770fe7e02 (diff) | |
| download | sncontinue-9adfb8bf5b9f44be82488e37bc32cbd9a8817b53.tar.gz sncontinue-9adfb8bf5b9f44be82488e37bc32cbd9a8817b53.tar.bz2 sncontinue-9adfb8bf5b9f44be82488e37bc32cbd9a8817b53.zip | |
Merge pull request #237 from continuedev/bug-squashing
Bug squashing
Diffstat (limited to 'extension/react-app/src')
| -rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 33 | ||||
| -rw-r--r-- | extension/react-app/src/tabs/gui.tsx | 11 | 
2 files changed, 31 insertions, 13 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); diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx index 0e60e05c..619b91e1 100644 --- a/extension/react-app/src/tabs/gui.tsx +++ b/extension/react-app/src/tabs/gui.tsx @@ -170,6 +170,7 @@ function GUI(props: GUIProps) {        const waitingForSteps =          state.active &&          state.history.current_index < state.history.timeline.length && +        state.history.timeline[state.history.current_index] &&          state.history.timeline[            state.history.current_index          ].step.description?.trim() === ""; @@ -236,14 +237,14 @@ function GUI(props: GUIProps) {          history.current_index < history.timeline.length        ) {          if ( -          history.timeline[history.current_index].step.name === +          history.timeline[history.current_index]?.step.name ===            "Waiting for user input"          ) {            if (input.trim() === "") return;            onStepUserInput(input, history!.current_index);            return;          } else if ( -          history.timeline[history.current_index].step.name === +          history.timeline[history.current_index]?.step.name ===            "Waiting for user confirmation"          ) {            onStepUserInput("ok", history!.current_index); @@ -350,12 +351,6 @@ function GUI(props: GUIProps) {          </div>          <ComboBox -          // disabled={ -          //   history?.timeline.length -          //     ? history.timeline[history.current_index].step.name === -          //       "Waiting for user confirmation" -          //     : false -          // }            ref={mainTextInputRef}            onEnter={(e) => {              onMainTextInput(e); | 
