Skip to content

Commit

Permalink
Fix a bug that can't load custom dictionary files if they have many w…
Browse files Browse the repository at this point in the history
…ords (#15)
  • Loading branch information
tadashi-aikawa committed Nov 20, 2021
1 parent 6354734 commit 79c523f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/ui/AutoCompleteSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ export class AutoCompleteSuggest extends EditorSuggest<string> {
try {
const buf = await FileSystemAdapter.readLocalFile(path);
const str = new TextDecoder().decode(buf);
this.customTokens.push(
...str.split(/(\r\n|\n)/).filter((x) => x !== "")
);
} catch {
for (const line of str.split(/(\r\n|\n)/)) {
if (line !== "") {
this.customTokens.push(line);
}
}
} catch (e) {
// noinspection ObjectAllocationIgnored
new Notice(`⚠ Fail to load ${path} -- Various Complements Plugin`);
new Notice(
`⚠ Fail to load ${path} -- Various Complements Plugin -- \n ${e}`,
0
);
}
}
}
Expand Down

0 comments on commit 79c523f

Please sign in to comment.