422
423
public async $textualSuggest(modelUrls: string[], leadingWord: string | undefined, wordDef: string, wordDefFlags: string): Promise<{ words: string[]; duration: number } | null> {
425
>
const sw = new StopWatch();
426
>
const wordDefRegExp = new RegExp(wordDef, wordDefFlags);
427
>
const seen = new Set<string>();
428
>
429
>
outer: for (const url of modelUrls) {
430
>
const model = this._getModel(url);
431
>
if (!model) {
432
continue;
433
}
435
>
for (const word of model.words(wordDefRegExp)) {
436
>
if (word === leadingWord || !isNaN(Number(word))) {
437
>
continue;
438
>
}
439
>
seen.add(word);
440
>
if (seen.size > EditorWorker._suggestionsLimit) {
441
break outer;
442
}
444
>
}
445
>
446
>
return { words: Array.from(seen), duration: sw.elapsed() };
447
>
}
448
449