From 767f7e1c9c7ecab7cc3515f0dabf3798a14df612 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 8 Dec 2024 21:30:03 -0800 Subject: [PATCH 1/2] fix autocomplete filtering cases --- .../streamTransforms/StreamTransformPipeline.ts | 7 +++++++ .../filtering/streamTransforms/lineStream.ts | 15 ++++++++++++++- core/autocomplete/filtering/test/testCases.ts | 12 ++++-------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index 55cde067a..180c339e6 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -10,6 +10,7 @@ import { showWhateverWeHaveAtXMs, skipPrefixes, stopAtLines, + stopAtLinesExact, stopAtRepeatingLines, stopAtSimilarLine, streamWithNewLines, @@ -42,6 +43,12 @@ export class StreamTransformPipeline { let lineGenerator = streamLines(charGenerator); lineGenerator = stopAtLines(lineGenerator, fullStop); + const lineBelowCursor = this.getLineBelowCursor(helper); + if (lineBelowCursor.trim() !== "") { + lineGenerator = stopAtLinesExact(lineGenerator, fullStop, [ + lineBelowCursor, + ]); + } lineGenerator = stopAtRepeatingLines(lineGenerator, fullStop); lineGenerator = avoidEmptyComments( lineGenerator, diff --git a/core/autocomplete/filtering/streamTransforms/lineStream.ts b/core/autocomplete/filtering/streamTransforms/lineStream.ts index aaeec1291..851dea88a 100644 --- a/core/autocomplete/filtering/streamTransforms/lineStream.ts +++ b/core/autocomplete/filtering/streamTransforms/lineStream.ts @@ -2,7 +2,6 @@ import { distance } from "fastest-levenshtein"; import { DiffLine } from "../../.."; import { LineStream } from "../../../diff/util"; -import { BRACKETS, BRACKETS_REVERSE } from "../BracketMatchingService"; export type LineFilter = (args: { lines: LineStream; @@ -270,6 +269,20 @@ export async function* stopAtLines( } } +export async function* stopAtLinesExact( + stream: LineStream, + fullStop: () => void, + linesToStopAt: string[], +): LineStream { + for await (const line of stream) { + if (linesToStopAt.some((stopAt) => line === stopAt)) { + fullStop(); + break; + } + yield line; + } +} + /** * Filters a LineStream, skipping specified prefixes on the first line. * @param {LineStream} lines - The input stream of lines. diff --git a/core/autocomplete/filtering/test/testCases.ts b/core/autocomplete/filtering/test/testCases.ts index 277c8cdc8..f83de1607 100644 --- a/core/autocomplete/filtering/test/testCases.ts +++ b/core/autocomplete/filtering/test/testCases.ts @@ -810,8 +810,7 @@ func main() {}`, }`, expectedCompletion: `string State string - ZipCode string -}`, + ZipCode string`, }, { @@ -1118,8 +1117,7 @@ impl Calculator { self.result /= number; } else { println!("Cannot divide by zero."); - } -}`, + }`, }, { description: "Should autocomplete Rust struct definition", @@ -1600,8 +1598,7 @@ interface User { age: number; }`, expectedCompletion: `mail: string; - age: number; -}`, + age: number;`, }, { description: "Should autocomplete TypeScript interface declarations", @@ -1853,8 +1850,7 @@ let john = { FirstName = "John"; LastName = "Doe"; Age = 30 }`, Address: string }`, expectedCompletion: ` - Address: string -}`, + Address: string`, }, { From fc11a987756ac0f43e1ae3ab1a624e7d77f44f2c Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 8 Dec 2024 21:30:22 -0800 Subject: [PATCH 2/2] update package.json --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 9cf7db2b1..b63ed82f9 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.241", + "version": "0.9.242", "repository": { "type": "git", "url": "https://github.com/continuedev/continue"