diff options
Diffstat (limited to 'extension')
-rw-r--r-- | extension/package-lock.json | 45 | ||||
-rw-r--r-- | extension/package.json | 3 | ||||
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 6 | ||||
-rw-r--r-- | extension/schema/FullState.d.ts | 2 | ||||
-rw-r--r-- | extension/src/activation/environmentSetup.ts | 69 | ||||
-rw-r--r-- | extension/src/diffs.ts | 19 |
6 files changed, 106 insertions, 38 deletions
diff --git a/extension/package-lock.json b/extension/package-lock.json index 043f0892..5733c2dd 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.0.125", + "version": "0.0.143", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.0.125", + "version": "0.0.143", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -21,6 +21,7 @@ "downshift": "^7.6.0", "fkill": "^8.1.0", "highlight.js": "^11.7.0", + "highlightable": "^1.3.0-beta.0", "posthog-js": "^1.68.3", "react-markdown": "^8.0.7", "react-redux": "^8.0.5", @@ -5809,6 +5810,22 @@ "node": ">=12.0.0" } }, + "node_modules/highlightable": { + "version": "1.3.0-beta.0", + "resolved": "https://registry.npmjs.org/highlightable/-/highlightable-1.3.0-beta.0.tgz", + "integrity": "sha512-pDgzsLBus8oscL7KOqZ5rVMXgCnEmoig+G5gWoDczMm1SFDsNLzRwmNjkJoKdiA3q0oW/f+VqZ3W2YzG5lXQYA==", + "dependencies": { + "@types/react": "^18.0.28", + "emoji-regex": "^10.2.1", + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/highlightable/node_modules/emoji-regex": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.2.1.tgz", + "integrity": "sha512-97g6QgOk8zlDRdgq1WxwgTMgEWGVAQvB5Fdpgc1MkNy56la5SKP9GsMXKDOdqwn90/41a8yPwIGk1Y6WVbeMQA==" + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -9424,7 +9441,6 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", - "peer": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -9436,7 +9452,6 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", - "peer": true, "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.0" @@ -9889,7 +9904,6 @@ "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", - "peer": true, "dependencies": { "loose-envify": "^1.1.0" } @@ -15741,6 +15755,24 @@ "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.7.0.tgz", "integrity": "sha512-1rRqesRFhMO/PRF+G86evnyJkCgaZFOI+Z6kdj15TA18funfoqJXvgPCLSf0SWq3SRfg1j3HlDs8o4s3EGq1oQ==" }, + "highlightable": { + "version": "1.3.0-beta.0", + "resolved": "https://registry.npmjs.org/highlightable/-/highlightable-1.3.0-beta.0.tgz", + "integrity": "sha512-pDgzsLBus8oscL7KOqZ5rVMXgCnEmoig+G5gWoDczMm1SFDsNLzRwmNjkJoKdiA3q0oW/f+VqZ3W2YzG5lXQYA==", + "requires": { + "@types/react": "^18.0.28", + "emoji-regex": "^10.2.1", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "dependencies": { + "emoji-regex": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.2.1.tgz", + "integrity": "sha512-97g6QgOk8zlDRdgq1WxwgTMgEWGVAQvB5Fdpgc1MkNy56la5SKP9GsMXKDOdqwn90/41a8yPwIGk1Y6WVbeMQA==" + } + } + }, "hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -18297,7 +18329,6 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", - "peer": true, "requires": { "loose-envify": "^1.1.0" } @@ -18306,7 +18337,6 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", - "peer": true, "requires": { "loose-envify": "^1.1.0", "scheduler": "^0.23.0" @@ -18622,7 +18652,6 @@ "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", - "peer": true, "requires": { "loose-envify": "^1.1.0" } diff --git a/extension/package.json b/extension/package.json index 1d4b8055..444372f8 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@ "displayName": "Continue", "pricing": "Free", "description": "The open-source coding autopilot", - "version": "0.0.125", + "version": "0.0.143", "publisher": "Continue", "engines": { "vscode": "^1.67.0" @@ -269,6 +269,7 @@ "downshift": "^7.6.0", "fkill": "^8.1.0", "highlight.js": "^11.7.0", + "highlightable": "^1.3.0-beta.0", "posthog-js": "^1.68.3", "react-markdown": "^8.0.7", "react-redux": "^8.0.5", diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index e6632360..801c3a03 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -224,8 +224,8 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { editing={section.editing} pinned={section.pinned} index={idx} - key={`${section.filepath}${idx}`} - title={`${section.range.filepath} (${ + key={`${section.display_name}${idx}`} + title={`${section.display_name} (${ section.range.range.start.line + 1 }-${section.range.range.end.line + 1})`} onDelete={() => { @@ -372,7 +372,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { > {highlightedCodeSections.map((section, idx) => ( <> - <p>{section.range.filepath}</p> + <p>{section.display_name}</p> <CodeBlock showCopy={false} key={idx}> {section.range.contents} </CodeBlock> diff --git a/extension/schema/FullState.d.ts b/extension/schema/FullState.d.ts index 981e772e..abb0832d 100644 --- a/extension/schema/FullState.d.ts +++ b/extension/schema/FullState.d.ts @@ -32,6 +32,7 @@ export type Character = number; export type Contents = string; export type Editing = boolean; export type Pinned = boolean; +export type DisplayName = string; export type HighlightedRanges = HighlightedRangeContext[]; export type Name3 = string; export type Description1 = string; @@ -102,6 +103,7 @@ export interface HighlightedRangeContext { range: RangeInFileWithContents; editing: Editing; pinned: Pinned; + display_name: DisplayName; [k: string]: unknown; } /** diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index bbf93f65..714080e3 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -189,32 +189,46 @@ async function setupPythonEnv() { `${pythonCmd} -m venv env`, ].join(" ; "); - // Repeat until it is successfully created (sometimes it fails to generate the bin, need to try again) - while (true) { - const [, stderr] = await runCommand(createEnvCommand); - if (checkEnvExists()) { - break; - } else if (stderr) { - if (stderr.includes("running scripts is disabled on this system")) { - vscode.window.showErrorMessage( - "A Python virtual enviroment cannot be activated because running scripts is disabled for this user. Please enable signed scripts to run with this command in PowerShell: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`, reload VS Code, and then try again." - ); - } + const [stdout, stderr] = await runCommand(createEnvCommand); + if ( + stderr && + stderr.includes("running scripts is disabled on this system") + ) { + await vscode.window.showErrorMessage( + "A Python virtual enviroment cannot be activated because running scripts is disabled for this user. Please enable signed scripts to run with this command in PowerShell: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`, reload VS Code, and then try again." + ); + throw new Error(stderr); + } else if ( + stderr?.includes("On Debian/Ubuntu systems") || + stdout?.includes("On Debian/Ubuntu systems") + ) { + // First, try to run the command to install python3-venv + let [stdout, stderr] = await runCommand(`${pythonCmd} --version`); + if (stderr) { throw new Error(stderr); - } else { - // Remove the env and try again - const removeCommand = `rm -rf "${path.join( - getExtensionUri().fsPath, - "scripts", - "env" - )}"`; - await runCommand(removeCommand); } + const version = stdout.split(" ")[1].split(".")[1]; + const installVenvCommand = `apt-get install python3.${version}-venv`; + await runCommand("apt-get update"); + // Ask the user to run the command to install python3-venv (requires sudo, so we can't) + // First, get the python version + const msg = `[Important] Continue needs to create a Python virtual environment, but python3.${version}-venv is not installed. Please run this command in your terminal: \`${installVenvCommand}\`, reload VS Code, and then try again.`; + console.log(msg); + await vscode.window.showErrorMessage(msg); + } else if (checkEnvExists()) { + console.log( + "Successfully set up python env at ", + getExtensionUri().fsPath + "/scripts/env" + ); + } else { + const msg = [ + "Python environment not successfully created. Trying again. Here was the stdout + stderr: ", + `stdout: ${stdout}`, + `stderr: ${stderr}`, + ].join("\n\n"); + console.log(msg); + throw new Error(msg); } - console.log( - "Successfully set up python env at ", - getExtensionUri().fsPath + "/scripts/env" - ); } await retryThenFail(async () => { @@ -310,7 +324,14 @@ export async function startContinuePythonServer() { } } console.log("Killing old server..."); - await fkill(":65432"); + try { + await fkill(":65432"); + } catch (e) { + console.log( + "Failed to kill old server, likely because it didn't exist:", + e + ); + } } // Do this after above check so we don't have to waste time setting up the env diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index dbfd8f59..b9ef8384 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -39,14 +39,25 @@ class DiffManager { originalFilepath: string, newFilepath: string ): vscode.TextEditor | undefined { - // If the file doesn't yet exist, don't open the diff editor - if (!fs.existsSync(newFilepath)) { + // If the file doesn't yet exist or the basename is a single digit number (git hash object or something), don't open the diff editor + if ( + !fs.existsSync(newFilepath) || + path.basename(originalFilepath).match(/^\d$/) + ) { return undefined; } const rightUri = vscode.Uri.parse(newFilepath); const leftUri = vscode.Uri.file(originalFilepath); const title = "Continue Diff"; + console.log( + "Opening diff window with ", + leftUri, + rightUri, + title, + newFilepath, + originalFilepath + ); vscode.commands.executeCommand("vscode.diff", leftUri, rightUri, title); const editor = vscode.window.activeTextEditor; @@ -112,11 +123,13 @@ class DiffManager { newFilepath = Array.from(this.diffs.keys())[0]; } if (!newFilepath) { + console.log("No newFilepath provided to accept the diff"); return; } // Get the diff info, copy new file to original, then delete from record and close the corresponding editor const diffInfo = this.diffs.get(newFilepath); if (!diffInfo) { + console.log("No corresponding diffInfo found for newFilepath"); return; } fs.writeFileSync( @@ -132,10 +145,12 @@ class DiffManager { newFilepath = Array.from(this.diffs.keys())[0]; } if (!newFilepath) { + console.log("No newFilepath provided to reject the diff"); return; } const diffInfo = this.diffs.get(newFilepath); if (!diffInfo) { + console.log("No corresponding diffInfo found for newFilepath"); return; } |