Skip to content

Commit

Permalink
Use DenoKvDictionary instead of SkkDictionary if config.databasePath …
Browse files Browse the repository at this point in the history
…is set
  • Loading branch information
uga-rosa committed Dec 27, 2023
1 parent 21b7ba1 commit 13ba335
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions denops/skkeleton/jisyo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RomanNum } from "./deps/roman.ts";
import { zip } from "./deps/std/collections.ts";
import type { CompletionData, RankData } from "./types.ts";
import { SkkDictionary } from "./jisyo/skk_dictionary.ts";
import { DenoKvDictionary } from "./jisyo/deno_kv.ts";
import { UserDictionary, UserDictionaryPath } from "./jisyo/user_dictionary.ts";
import { SkkServer } from "./jisyo/skk_server.ts";
import { GoogleJapaneseInput } from "./jisyo/google_japanese_input.ts";
Expand Down Expand Up @@ -263,17 +264,24 @@ export async function load(
): Promise<Library> {
const globalDictionaries = await Promise.all(
globalDictionaryConfig.map(async ([path, encodingName]) => {
const dict = new SkkDictionary();
try {
await dict.load(path, encodingName);
if (config.databasePath) {
const dict = await DenoKvDictionary.create(path, encodingName);
await dict.load();
return dict;
} else {
const dict = new SkkDictionary();
await dict.load(path, encodingName);
return dict;
}
} catch (e) {
console.error("globalDictionary loading failed");
console.error(`at ${path}`);
if (config.debug) {
console.error(e);
}
return new SkkDictionary();
}
return dict;
}),
);

Expand Down

0 comments on commit 13ba335

Please sign in to comment.