🩹 various small updates

This commit is contained in:
Nate Sesti 2024-04-27 23:10:26 -07:00
parent 721ce6c799
commit 38bce7d138
3 changed files with 38 additions and 34 deletions

4
.gitignore vendored
View file

@ -152,4 +152,6 @@ continue_server.build
continue_server.dist
Icon
Icon?
Icon?
.continue

View file

@ -313,12 +313,6 @@
"command": "continue.newSession"
}
],
"webview/context": [
{
"command": "continue.shareSession",
"group": "navigation@1"
}
],
"editor/context": [
{
"submenu": "continue.continueSubMenu",

View file

@ -73,36 +73,44 @@ export async function getDefinitionsFromLsp(
cursorIndex: number,
ide: IDE,
): Promise<AutocompleteSnippet[]> {
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 [];
}
}