Skip to content

Commit 4d01ed7

Browse files
test: lineStream.ts
1 parent 6374b4d commit 4d01ed7

File tree

4 files changed

+674
-112
lines changed

4 files changed

+674
-112
lines changed

core/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ target
44
npm-debug.log*
55
.env
66
.continue-test
7-
testDir
7+
testDir
8+
coverage

core/autocomplete/completionProvider.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
import { isOnlyPunctuationAndWhitespace } from "./filter.js";
3838
import { AutocompleteLanguageInfo } from "./languages.js";
3939
import {
40-
avoidPathLine,
40+
avoidPathLineAndEmptyComments,
4141
noTopLevelKeywordsMidline,
4242
skipPrefixes,
4343
stopAtLines,
@@ -478,9 +478,9 @@ export class CompletionProvider {
478478
const lines = fullPrefix.split("\n");
479479
fullPrefix = `${lines.slice(0, -1).join("\n")}\n${
480480
lang.singleLineComment
481-
} ${input.injectDetails.split("\n").join(`\n${lang.singleLineComment} `)}\n${
482-
lines[lines.length - 1]
483-
}`;
481+
} ${input.injectDetails
482+
.split("\n")
483+
.join(`\n${lang.singleLineComment} `)}\n${lines[lines.length - 1]}`;
484484
}
485485

486486
const fullSuffix = getRangeInString(fileContents, {
@@ -581,7 +581,10 @@ export class CompletionProvider {
581581
prefix = `${formattedSnippets}\n\n${prefix}`;
582582
} else if (prefix.trim().length === 0 && suffix.trim().length === 0) {
583583
// If it's an empty file, include the file name as a comment
584-
prefix = `${lang.singleLineComment} ${getLastNPathParts(filepath, 2)}\n${prefix}`;
584+
prefix = `${lang.singleLineComment} ${getLastNPathParts(
585+
filepath,
586+
2,
587+
)}\n${prefix}`;
585588
}
586589

587590
prompt = compiledTemplate({
@@ -689,7 +692,10 @@ export class CompletionProvider {
689692
let lineGenerator = streamLines(charGenerator);
690693
lineGenerator = stopAtLines(lineGenerator, fullStop);
691694
lineGenerator = stopAtRepeatingLines(lineGenerator, fullStop);
692-
lineGenerator = avoidPathLine(lineGenerator, lang.singleLineComment);
695+
lineGenerator = avoidPathLineAndEmptyComments(
696+
lineGenerator,
697+
lang.singleLineComment,
698+
);
693699
lineGenerator = skipPrefixes(lineGenerator);
694700
lineGenerator = noTopLevelKeywordsMidline(
695701
lineGenerator,

0 commit comments

Comments
 (0)