Skip to content

Commit 1eafa16

Browse files
committed
fix small autocomplete bug in merge function
1 parent 8754465 commit 1eafa16

File tree

10 files changed

+128
-14
lines changed

10 files changed

+128
-14
lines changed

core/autocomplete/constructPrompt.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export async function constructAutocompletePrompt(
215215
snippets.push(...importSnippets);
216216
}
217217

218-
if (options.useHierarchicalContext && treePath) {
218+
if (options.useRootPathContext && treePath) {
219219
const ctx = await rootPathContextService.getContextForPath(
220220
filepath,
221221
treePath,

core/autocomplete/ranking.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function deduplicateSnippets(
8080
function mergeSnippetsByRange(
8181
snippets: Required<AutocompleteSnippet>[],
8282
): Required<AutocompleteSnippet>[] {
83-
if (snippets.length === 0) {
83+
if (snippets.length <= 1) {
8484
return snippets;
8585
}
8686

core/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ export interface TabAutocompleteOptions {
882882
recentLinePrefixMatchMinLength: number;
883883
disableInFiles?: string[];
884884
useImports?: boolean;
885-
useHierarchicalContext?: boolean;
885+
useRootPathContext?: boolean;
886886
}
887887

888888
export interface ContinueUIConfig {

core/util/parameters.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = {
2020
recentLinePrefixMatchMinLength: 7,
2121
disableInFiles: undefined,
2222
useImports: true,
23-
useHierarchicalContext: true,
23+
useRootPathContext: true,
2424
};
2525

2626
export const COUNT_COMPLETION_REJECTED_AFTER = 10_000;

core/util/treeSitter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export async function getLanguageForFile(
129129
export enum TSQueryType {
130130
CodeSnippets = "code-snippet-queries",
131131
Imports = "import-queries",
132-
// Used in HierarchicalContextService.ts
132+
// Used in RootPathContextService.ts
133133
FunctionDeclaration = "root-path-context-queries/function_declaration",
134134
MethodDefinition = "root-path-context-queries/method_definition",
135135
FunctionDefinition = "root-path-context-queries/function_definition",

docs/static/schemas/config.json

+34-2
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,8 @@
15521552
"url",
15531553
"database",
15541554
"os",
1555-
"repo-map"
1555+
"repo-map",
1556+
"greptile"
15561557
],
15571558
"markdownEnumDescriptions": [
15581559
"Reference the contents of the current changes as given by `git diff`",
@@ -1576,7 +1577,8 @@
15761577
"Reference the contents of a page at a URL",
15771578
"Reference table schemas",
15781579
"Operating system and CPU Information",
1579-
"Map of files in the repository with important code highlights"
1580+
"Map of files in the repository with important code highlights",
1581+
"Query your greptile index of the current repo"
15801582
],
15811583
"type": "string"
15821584
},
@@ -1954,6 +1956,36 @@
19541956
},
19551957
"required": ["host", "port", "user", "password", "database"]
19561958
}
1959+
},
1960+
{
1961+
"if": {
1962+
"properties": {
1963+
"name": {
1964+
"enum": ["greptile"]
1965+
}
1966+
}
1967+
},
1968+
"then": {
1969+
"properties": {
1970+
"params": {
1971+
"properties": {
1972+
"GithubToken": {
1973+
"title": "GithubToken",
1974+
"description": "Your github access token",
1975+
"default": "",
1976+
"type": "string"
1977+
},
1978+
"GreptileToken": {
1979+
"title": "GreptileToken",
1980+
"description": "Your greptile access token",
1981+
"default": "",
1982+
"type": "string"
1983+
}
1984+
}
1985+
}
1986+
},
1987+
"required": ["GreptileToken", "GithubToken"]
1988+
}
19571989
}
19581990
],
19591991
"required": ["name"]

extensions/intellij/src/main/resources/config_schema.json

+34-2
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,8 @@
15521552
"url",
15531553
"database",
15541554
"os",
1555-
"repo-map"
1555+
"repo-map",
1556+
"greptile"
15561557
],
15571558
"markdownEnumDescriptions": [
15581559
"Reference the contents of the current changes as given by `git diff`",
@@ -1576,7 +1577,8 @@
15761577
"Reference the contents of a page at a URL",
15771578
"Reference table schemas",
15781579
"Operating system and CPU Information",
1579-
"Map of files in the repository with important code highlights"
1580+
"Map of files in the repository with important code highlights",
1581+
"Query your greptile index of the current repo"
15801582
],
15811583
"type": "string"
15821584
},
@@ -1954,6 +1956,36 @@
19541956
},
19551957
"required": ["host", "port", "user", "password", "database"]
19561958
}
1959+
},
1960+
{
1961+
"if": {
1962+
"properties": {
1963+
"name": {
1964+
"enum": ["greptile"]
1965+
}
1966+
}
1967+
},
1968+
"then": {
1969+
"properties": {
1970+
"params": {
1971+
"properties": {
1972+
"GithubToken": {
1973+
"title": "GithubToken",
1974+
"description": "Your github access token",
1975+
"default": "",
1976+
"type": "string"
1977+
},
1978+
"GreptileToken": {
1979+
"title": "GreptileToken",
1980+
"description": "Your greptile access token",
1981+
"default": "",
1982+
"type": "string"
1983+
}
1984+
}
1985+
}
1986+
},
1987+
"required": ["GreptileToken", "GithubToken"]
1988+
}
19571989
}
19581990
],
19591991
"required": ["name"]

extensions/vscode/continue_rc_schema.json

+39-2
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,8 @@
17231723
"url",
17241724
"database",
17251725
"os",
1726-
"repo-map"
1726+
"repo-map",
1727+
"greptile"
17271728
],
17281729
"markdownEnumDescriptions": [
17291730
"Reference the contents of the current changes as given by `git diff`",
@@ -1747,7 +1748,8 @@
17471748
"Reference the contents of a page at a URL",
17481749
"Reference table schemas",
17491750
"Operating system and CPU Information",
1750-
"Map of files in the repository with important code highlights"
1751+
"Map of files in the repository with important code highlights",
1752+
"Query your greptile index of the current repo"
17511753
],
17521754
"type": "string"
17531755
},
@@ -2190,6 +2192,41 @@
21902192
"database"
21912193
]
21922194
}
2195+
},
2196+
{
2197+
"if": {
2198+
"properties": {
2199+
"name": {
2200+
"enum": [
2201+
"greptile"
2202+
]
2203+
}
2204+
}
2205+
},
2206+
"then": {
2207+
"properties": {
2208+
"params": {
2209+
"properties": {
2210+
"GithubToken": {
2211+
"title": "GithubToken",
2212+
"description": "Your github access token",
2213+
"default": "",
2214+
"type": "string"
2215+
},
2216+
"GreptileToken": {
2217+
"title": "GreptileToken",
2218+
"description": "Your greptile access token",
2219+
"default": "",
2220+
"type": "string"
2221+
}
2222+
}
2223+
}
2224+
},
2225+
"required": [
2226+
"GreptileToken",
2227+
"GithubToken"
2228+
]
2229+
}
21932230
}
21942231
],
21952232
"required": [

extensions/vscode/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/vscode/src/autocomplete/lsp.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { IDE, RangeInFile } from "core";
1+
import type { IDE, Range, RangeInFile } from "core";
22
import { getAst, getTreePathAtCursor } from "core/autocomplete/ast";
33
import { GetLspDefinitionsFunction } from "core/autocomplete/completionProvider";
44
import { AutocompleteLanguageInfo } from "core/autocomplete/languages";
@@ -303,6 +303,19 @@ export async function getDefinitionsForNode(
303303
}
304304
return await Promise.all(
305305
ranges.map(async (rif) => {
306+
// Convert the VS Code Range type to ours
307+
const range: Range = {
308+
start: {
309+
line: rif.range.start.line,
310+
character: rif.range.start.character,
311+
},
312+
end: {
313+
line: rif.range.end.line,
314+
character: rif.range.end.character,
315+
},
316+
};
317+
rif.range = range;
318+
306319
if (!isRifWithContents(rif)) {
307320
return {
308321
...rif,

0 commit comments

Comments
 (0)