fix small autocomplete bug in merge function

This commit is contained in:
Nate 2024-09-30 15:12:15 -07:00
parent 8754465406
commit 1eafa16bcd
10 changed files with 128 additions and 14 deletions

View file

@ -215,7 +215,7 @@ export async function constructAutocompletePrompt(
snippets.push(...importSnippets);
}
if (options.useHierarchicalContext && treePath) {
if (options.useRootPathContext && treePath) {
const ctx = await rootPathContextService.getContextForPath(
filepath,
treePath,

View file

@ -80,7 +80,7 @@ export function deduplicateSnippets(
function mergeSnippetsByRange(
snippets: Required<AutocompleteSnippet>[],
): Required<AutocompleteSnippet>[] {
if (snippets.length === 0) {
if (snippets.length <= 1) {
return snippets;
}

2
core/index.d.ts vendored
View file

@ -882,7 +882,7 @@ export interface TabAutocompleteOptions {
recentLinePrefixMatchMinLength: number;
disableInFiles?: string[];
useImports?: boolean;
useHierarchicalContext?: boolean;
useRootPathContext?: boolean;
}
export interface ContinueUIConfig {

View file

@ -20,7 +20,7 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = {
recentLinePrefixMatchMinLength: 7,
disableInFiles: undefined,
useImports: true,
useHierarchicalContext: true,
useRootPathContext: true,
};
export const COUNT_COMPLETION_REJECTED_AFTER = 10_000;

View file

@ -129,7 +129,7 @@ export async function getLanguageForFile(
export enum TSQueryType {
CodeSnippets = "code-snippet-queries",
Imports = "import-queries",
// Used in HierarchicalContextService.ts
// Used in RootPathContextService.ts
FunctionDeclaration = "root-path-context-queries/function_declaration",
MethodDefinition = "root-path-context-queries/method_definition",
FunctionDefinition = "root-path-context-queries/function_definition",

View file

@ -1552,7 +1552,8 @@
"url",
"database",
"os",
"repo-map"
"repo-map",
"greptile"
],
"markdownEnumDescriptions": [
"Reference the contents of the current changes as given by `git diff`",
@ -1576,7 +1577,8 @@
"Reference the contents of a page at a URL",
"Reference table schemas",
"Operating system and CPU Information",
"Map of files in the repository with important code highlights"
"Map of files in the repository with important code highlights",
"Query your greptile index of the current repo"
],
"type": "string"
},
@ -1954,6 +1956,36 @@
},
"required": ["host", "port", "user", "password", "database"]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["greptile"]
}
}
},
"then": {
"properties": {
"params": {
"properties": {
"GithubToken": {
"title": "GithubToken",
"description": "Your github access token",
"default": "",
"type": "string"
},
"GreptileToken": {
"title": "GreptileToken",
"description": "Your greptile access token",
"default": "",
"type": "string"
}
}
}
},
"required": ["GreptileToken", "GithubToken"]
}
}
],
"required": ["name"]

View file

@ -1552,7 +1552,8 @@
"url",
"database",
"os",
"repo-map"
"repo-map",
"greptile"
],
"markdownEnumDescriptions": [
"Reference the contents of the current changes as given by `git diff`",
@ -1576,7 +1577,8 @@
"Reference the contents of a page at a URL",
"Reference table schemas",
"Operating system and CPU Information",
"Map of files in the repository with important code highlights"
"Map of files in the repository with important code highlights",
"Query your greptile index of the current repo"
],
"type": "string"
},
@ -1954,6 +1956,36 @@
},
"required": ["host", "port", "user", "password", "database"]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["greptile"]
}
}
},
"then": {
"properties": {
"params": {
"properties": {
"GithubToken": {
"title": "GithubToken",
"description": "Your github access token",
"default": "",
"type": "string"
},
"GreptileToken": {
"title": "GreptileToken",
"description": "Your greptile access token",
"default": "",
"type": "string"
}
}
}
},
"required": ["GreptileToken", "GithubToken"]
}
}
],
"required": ["name"]

View file

@ -1723,7 +1723,8 @@
"url",
"database",
"os",
"repo-map"
"repo-map",
"greptile"
],
"markdownEnumDescriptions": [
"Reference the contents of the current changes as given by `git diff`",
@ -1747,7 +1748,8 @@
"Reference the contents of a page at a URL",
"Reference table schemas",
"Operating system and CPU Information",
"Map of files in the repository with important code highlights"
"Map of files in the repository with important code highlights",
"Query your greptile index of the current repo"
],
"type": "string"
},
@ -2190,6 +2192,41 @@
"database"
]
}
},
{
"if": {
"properties": {
"name": {
"enum": [
"greptile"
]
}
}
},
"then": {
"properties": {
"params": {
"properties": {
"GithubToken": {
"title": "GithubToken",
"description": "Your github access token",
"default": "",
"type": "string"
},
"GreptileToken": {
"title": "GreptileToken",
"description": "Your greptile access token",
"default": "",
"type": "string"
}
}
}
},
"required": [
"GreptileToken",
"GithubToken"
]
}
}
],
"required": [

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.9.213",
"version": "0.9.214",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.9.213",
"version": "0.9.214",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",

View file

@ -1,4 +1,4 @@
import type { IDE, RangeInFile } from "core";
import type { IDE, Range, RangeInFile } from "core";
import { getAst, getTreePathAtCursor } from "core/autocomplete/ast";
import { GetLspDefinitionsFunction } from "core/autocomplete/completionProvider";
import { AutocompleteLanguageInfo } from "core/autocomplete/languages";
@ -303,6 +303,19 @@ export async function getDefinitionsForNode(
}
return await Promise.all(
ranges.map(async (rif) => {
// Convert the VS Code Range type to ours
const range: Range = {
start: {
line: rif.range.start.line,
character: rif.range.start.character,
},
end: {
line: rif.range.end.line,
character: rif.range.end.character,
},
};
rif.range = range;
if (!isRifWithContents(rif)) {
return {
...rif,