🐛 fix autocomplete bug
This commit is contained in:
parent
2abdfe1ec4
commit
d98264ac5a
3 changed files with 12 additions and 8 deletions
|
|
@ -237,17 +237,18 @@ export async function getTabCompletion(
|
|||
for await (const update of generator) {
|
||||
if (token.aborted) {
|
||||
cancelled = true;
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
yield update;
|
||||
}
|
||||
};
|
||||
let chars = generatorWithCancellation();
|
||||
const gen2 = onlyWhitespaceAfterEndOfLine(
|
||||
noFirstCharNewline(chars),
|
||||
lang.endOfLine,
|
||||
);
|
||||
let lineGenerator = stopAtRepeatingLines(stopAtLines(streamLines(gen2)));
|
||||
let charGenerator = generatorWithCancellation();
|
||||
charGenerator = noFirstCharNewline(charGenerator);
|
||||
charGenerator = onlyWhitespaceAfterEndOfLine(charGenerator, lang.endOfLine);
|
||||
|
||||
let lineGenerator = streamLines(charGenerator);
|
||||
lineGenerator = stopAtLines(lineGenerator);
|
||||
lineGenerator = stopAtRepeatingLines(lineGenerator);
|
||||
lineGenerator = avoidPathLine(lineGenerator, lang.comment);
|
||||
lineGenerator = noTopLevelKeywordsMidline(lineGenerator, lang.stopWords);
|
||||
lineGenerator = streamWithNewLines(lineGenerator);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export interface AutocompleteLanguageInfo {
|
|||
|
||||
// TypeScript
|
||||
export const Typescript = {
|
||||
stopWords: ["function", "class", "module", "export"],
|
||||
stopWords: ["function", "class", "module", "export", "import"],
|
||||
comment: "//",
|
||||
endOfLine: [";"],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ export class ListenableGenerator<T> {
|
|||
async *tee(): AsyncGenerator<T> {
|
||||
try {
|
||||
let i = 0;
|
||||
while (i < this._buffer.length) {
|
||||
yield this._buffer[i++];
|
||||
}
|
||||
while (!this._isEnded) {
|
||||
let resolve: (value: any) => void;
|
||||
let promise = new Promise<T>((res) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue