From 1eafa16bcd8581a40c02182883ecc007328c6747 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 30 Sep 2024 15:12:15 -0700 Subject: [PATCH] fix small autocomplete bug in merge function --- core/autocomplete/constructPrompt.ts | 2 +- core/autocomplete/ranking.ts | 2 +- core/index.d.ts | 2 +- core/util/parameters.ts | 2 +- core/util/treeSitter.ts | 2 +- docs/static/schemas/config.json | 36 +++++++++++++++- .../src/main/resources/config_schema.json | 36 +++++++++++++++- extensions/vscode/continue_rc_schema.json | 41 ++++++++++++++++++- extensions/vscode/package-lock.json | 4 +- extensions/vscode/src/autocomplete/lsp.ts | 15 ++++++- 10 files changed, 128 insertions(+), 14 deletions(-) diff --git a/core/autocomplete/constructPrompt.ts b/core/autocomplete/constructPrompt.ts index 43324ea8c..f3d08ff5c 100644 --- a/core/autocomplete/constructPrompt.ts +++ b/core/autocomplete/constructPrompt.ts @@ -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, diff --git a/core/autocomplete/ranking.ts b/core/autocomplete/ranking.ts index 51791794c..48e01d5ff 100644 --- a/core/autocomplete/ranking.ts +++ b/core/autocomplete/ranking.ts @@ -80,7 +80,7 @@ export function deduplicateSnippets( function mergeSnippetsByRange( snippets: Required[], ): Required[] { - if (snippets.length === 0) { + if (snippets.length <= 1) { return snippets; } diff --git a/core/index.d.ts b/core/index.d.ts index 11cf3a503..c1c8ddc04 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -882,7 +882,7 @@ export interface TabAutocompleteOptions { recentLinePrefixMatchMinLength: number; disableInFiles?: string[]; useImports?: boolean; - useHierarchicalContext?: boolean; + useRootPathContext?: boolean; } export interface ContinueUIConfig { diff --git a/core/util/parameters.ts b/core/util/parameters.ts index 26336b3f3..88c7d38a6 100644 --- a/core/util/parameters.ts +++ b/core/util/parameters.ts @@ -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; diff --git a/core/util/treeSitter.ts b/core/util/treeSitter.ts index 043906547..08cfe64d1 100644 --- a/core/util/treeSitter.ts +++ b/core/util/treeSitter.ts @@ -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", diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 1f8e85f73..3f340f6ce 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -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"] diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 1f8e85f73..3f340f6ce 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -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"] diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index a5ce1dbc4..26877d8a3 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -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": [ diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 05833b84e..5bfd16377 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -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", diff --git a/extensions/vscode/src/autocomplete/lsp.ts b/extensions/vscode/src/autocomplete/lsp.ts index 220b259d5..f24b23bf3 100644 --- a/extensions/vscode/src/autocomplete/lsp.ts +++ b/extensions/vscode/src/autocomplete/lsp.ts @@ -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,