Merge pull request #3254 from continuedev/nate/quick-edit-b3e2

fix autocomplete filtering cases
This commit is contained in:
Nate Sesti 2024-12-08 21:41:27 -08:00 • committed by GitHub
commit c8a7bf90fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 10 deletions

View file

@ -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,

View file

@ -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.

View file

@ -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`,
},
{

View file

@ -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"