diff options
Diffstat (limited to 'extension')
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 49 | ||||
-rw-r--r-- | extension/react-app/src/components/PillButton.tsx | 6 | ||||
-rw-r--r-- | extension/src/activation/environmentSetup.ts | 61 |
3 files changed, 78 insertions, 38 deletions
diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 4e564000..b189e442 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -137,7 +137,9 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { const searchClient = new MeiliSearch({ host: "http://127.0.0.1:7700" }); const client = useContext(GUIClientContext); const dispatch = useDispatch(); - const workspacePaths = useSelector((state: RootStore) => state.config.workspacePaths); + const workspacePaths = useSelector( + (state: RootStore) => state.config.workspacePaths + ); const [history, setHistory] = React.useState<string[]>([]); // The position of the current command you are typing now, so the one that will be appended to history once you press enter @@ -184,10 +186,12 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { setCurrentlyInContextQuery(true); const providerAndQuery = segs[segs.length - 1] || ""; // Only return context items from the current workspace - the index is currently shared between all sessions - const workspaceFilter = - workspacePaths && workspacePaths.length > 0 - ? `workspace_dir IN [ ${workspacePaths.map((path) => `"${path}"`).join(", ")} ]` - : undefined; + const workspaceFilter = + workspacePaths && workspacePaths.length > 0 + ? `workspace_dir IN [ ${workspacePaths + .map((path) => `"${path}"`) + .join(", ")} ]` + : undefined; searchClient .index(SEARCH_INDEX_NAME) .search(providerAndQuery, { @@ -418,21 +422,30 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { // Prevent Downshift's default 'Enter' behavior. (event.nativeEvent as any).preventDownshiftDefault = true; - if (props.onEnter) {props.onEnter(event);} + if (props.onEnter) { + props.onEnter(event); + } setCurrentlyInContextQuery(false); } else if (event.key === "Tab" && items.length > 0) { downshiftProps.setInputValue(items[0].name); event.preventDefault(); } else if (event.key === "Tab") { (event.nativeEvent as any).preventDownshiftDefault = true; - } else if ( - (event.key === "ArrowUp" || event.key === "ArrowDown") && - event.currentTarget.value.split("\n").length > 1 - ) { - (event.nativeEvent as any).preventDownshiftDefault = true; } else if (event.key === "ArrowUp") { - if (positionInHistory == 0) {return;} - else if ( + // Only go back in history if selectionStart is 0 + // (i.e. the cursor is at the beginning of the input) + if ( + positionInHistory == 0 || + event.currentTarget.selectionStart !== 0 + ) { + console.log( + "returning", + positionInHistory, + event.currentTarget.selectionStart + ); + (event.nativeEvent as any).preventDownshiftDefault = true; + return; + } else if ( positionInHistory == history.length && (history.length === 0 || history[history.length - 1] !== event.currentTarget.value) @@ -443,6 +456,15 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { setPositionInHistory((prev) => prev - 1); setCurrentlyInContextQuery(false); } else if (event.key === "ArrowDown") { + if ( + positionInHistory === history.length || + event.currentTarget.selectionStart !== + event.currentTarget.value.length + ) { + (event.nativeEvent as any).preventDownshiftDefault = true; + return; + } + if (positionInHistory < history.length) { downshiftProps.setInputValue(history[positionInHistory + 1]); } @@ -454,6 +476,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { setCurrentlyInContextQuery(false); if (downshiftProps.isOpen && items.length > 0) { downshiftProps.closeMenu(); + (event.nativeEvent as any).preventDownshiftDefault = true; } else { (event.nativeEvent as any).preventDownshiftDefault = true; // Remove focus from the input diff --git a/extension/react-app/src/components/PillButton.tsx b/extension/react-app/src/components/PillButton.tsx index 0dcd43eb..1ffdeeed 100644 --- a/extension/react-app/src/components/PillButton.tsx +++ b/extension/react-app/src/components/PillButton.tsx @@ -106,7 +106,7 @@ const StyledButton = styled(Button)<StyledButtonProps>` &:focus { outline: none; - border-color: red; + border-color: ${vscForeground}; border-width: 1px; border-style: solid; } @@ -185,13 +185,13 @@ const PillButton = (props: PillButtonProps) => { <GridDiv style={{ gridTemplateColumns: - props.item.editable && props.addingHighlightedCode + props.item.editable && props.areMultipleItems ? "1fr 1fr" : "1fr", backgroundColor: vscBackground, }} > - {props.item.editable && props.addingHighlightedCode && ( + {props.item.editable && props.areMultipleItems && ( <ButtonDiv data-tooltip-id={`edit-${props.index}`} backgroundColor={"#8800aa55"} diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 748a5984..3ff9137e 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -94,7 +94,7 @@ async function checkOrKillRunningServer(serverUrl: string): Promise<boolean> { if (serverRunning) { console.log("Killing server from old version of Continue"); try { - await fkill(":65432"); + await fkill(":65432", { force: true }); } catch (e: any) { if (!e.message.includes("Process doesn't exist")) { console.log("Failed to kill old server:", e); @@ -236,28 +236,45 @@ export async function startContinuePythonServer() { setTimeout(spawnChild, delay); }; try { - const child = spawn(destination, { + // NodeJS bug requires not using detached on Windows, otherwise windowsHide is ineffective + // Otherwise, detach is preferable + const windowsSettings = { windowsHide: true, - }); - child.stdout.on("data", (data: any) => { - // console.log(`stdout: ${data}`); - }); - child.stderr.on("data", (data: any) => { - console.log(`stderr: ${data}`); - }); - child.on("error", (err: any) => { - if (attempts < maxAttempts) { - retry(); - } else { - console.error("Failed to start subprocess.", err); - } - }); - child.on("exit", (code: any, signal: any) => { - console.log("Subprocess exited with code", code, signal); - }); - child.on("close", (code: any, signal: any) => { - console.log("Subprocess closed with code", code, signal); - }); + }; + const macLinuxSettings = { + detached: true, + stdio: "ignore", + }; + const settings: any = + os.platform() === "win32" ? windowsSettings : macLinuxSettings; + + // Spawn the server + const child = spawn(destination, settings); + + // Either unref to avoid zombie process, or listen to events because you can + if (os.platform() === "win32") { + child.stdout.on("data", (data: any) => { + // console.log(`stdout: ${data}`); + }); + child.stderr.on("data", (data: any) => { + console.log(`stderr: ${data}`); + }); + child.on("error", (err: any) => { + if (attempts < maxAttempts) { + retry(); + } else { + console.error("Failed to start subprocess.", err); + } + }); + child.on("exit", (code: any, signal: any) => { + console.log("Subprocess exited with code", code, signal); + }); + child.on("close", (code: any, signal: any) => { + console.log("Subprocess closed with code", code, signal); + }); + } else { + child.unref(); + } } catch (e: any) { console.log("Error starting server:", e); retry(); |