Skip to content

Commit

Permalink
test: lineStream.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick-Erichsen committed Aug 16, 2024
1 parent 6374b4d commit 4d01ed7
Show file tree
Hide file tree
Showing 4 changed files with 674 additions and 112 deletions.
3 changes: 2 additions & 1 deletion core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ target
npm-debug.log*
.env
.continue-test
testDir
testDir
coverage
18 changes: 12 additions & 6 deletions core/autocomplete/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
import { isOnlyPunctuationAndWhitespace } from "./filter.js";
import { AutocompleteLanguageInfo } from "./languages.js";
import {
avoidPathLine,
avoidPathLineAndEmptyComments,
noTopLevelKeywordsMidline,
skipPrefixes,
stopAtLines,
Expand Down Expand Up @@ -478,9 +478,9 @@ export class CompletionProvider {
const lines = fullPrefix.split("\n");
fullPrefix = `${lines.slice(0, -1).join("\n")}\n${
lang.singleLineComment
} ${input.injectDetails.split("\n").join(`\n${lang.singleLineComment} `)}\n${
lines[lines.length - 1]
}`;
} ${input.injectDetails
.split("\n")
.join(`\n${lang.singleLineComment} `)}\n${lines[lines.length - 1]}`;
}

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

prompt = compiledTemplate({
Expand Down Expand Up @@ -689,7 +692,10 @@ export class CompletionProvider {
let lineGenerator = streamLines(charGenerator);
lineGenerator = stopAtLines(lineGenerator, fullStop);
lineGenerator = stopAtRepeatingLines(lineGenerator, fullStop);
lineGenerator = avoidPathLine(lineGenerator, lang.singleLineComment);
lineGenerator = avoidPathLineAndEmptyComments(
lineGenerator,
lang.singleLineComment,
);
lineGenerator = skipPrefixes(lineGenerator);
lineGenerator = noTopLevelKeywordsMidline(
lineGenerator,
Expand Down
Loading

0 comments on commit 4d01ed7

Please sign in to comment.