From 38bce7d13829b19d1f34971c9cbd284efd3ed224 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 27 Apr 2024 23:10:26 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20various=20small=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- extensions/vscode/package.json | 6 --- extensions/vscode/src/autocomplete/lsp.ts | 62 +++++++++++++---------- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index f8d2c8a18..f13fbe108 100644 --- a/.gitignore +++ b/.gitignore @@ -152,4 +152,6 @@ continue_server.build continue_server.dist Icon -Icon? \ No newline at end of file +Icon? + +.continue \ No newline at end of file diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 6604670d0..7f9bb2926 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -313,12 +313,6 @@ "command": "continue.newSession" } ], - "webview/context": [ - { - "command": "continue.shareSession", - "group": "navigation@1" - } - ], "editor/context": [ { "submenu": "continue.continueSubMenu", diff --git a/extensions/vscode/src/autocomplete/lsp.ts b/extensions/vscode/src/autocomplete/lsp.ts index ca7600424..0b6fb74ad 100644 --- a/extensions/vscode/src/autocomplete/lsp.ts +++ b/extensions/vscode/src/autocomplete/lsp.ts @@ -73,36 +73,44 @@ export async function getDefinitionsFromLsp( cursorIndex: number, ide: IDE, ): Promise { - const ast = await getAst(filepath, contents); - if (!ast) return []; + try { + const ast = await getAst(filepath, contents); + if (!ast) return []; - const treePath = await getTreePathAtCursor(ast, cursorIndex); - if (!treePath) return []; + const treePath = await getTreePathAtCursor(ast, cursorIndex); + if (!treePath) return []; - const results: RangeInFileWithContents[] = []; - for (const node of treePath.reverse()) { - const definitions = await getDefinitionsForNode(filepath, node); - results.push( - ...(await Promise.all( - definitions.map(async (def) => ({ - ...def, - contents: await ide.readRangeInFile( - def.filepath, - new vscode.Range( - new vscode.Position( - def.range.start.line, - def.range.start.character, + const results: RangeInFileWithContents[] = []; + for (const node of treePath.reverse()) { + const definitions = await getDefinitionsForNode(filepath, node); + results.push( + ...(await Promise.all( + definitions.map(async (def) => ({ + ...def, + contents: await ide.readRangeInFile( + def.filepath, + new vscode.Range( + new vscode.Position( + def.range.start.line, + def.range.start.character, + ), + new vscode.Position( + def.range.end.line, + def.range.end.character, + ), ), - new vscode.Position(def.range.end.line, def.range.end.character), ), - ), - })), - )), - ); - } + })), + )), + ); + } - return results.map((result) => ({ - ...result, - score: 0.8, - })); + return results.map((result) => ({ + ...result, + score: 0.8, + })); + } catch (e) { + console.warn("Error getting definitions from LSP: ", e); + return []; + } }