Skip to content

Commit

Permalink
feat: determine AffixType as early as possible
Browse files Browse the repository at this point in the history
`affix()` is more robust thant `henkanFirst()` because
`affix()` is `state.type`-aware.

`henkanFirst()` may determine AffixType if it is undefined.
However, the result might be wrong because prefix has higher priority
than suffix.
  • Loading branch information
atusy committed Jun 8, 2024
1 parent 846f29b commit 1a052e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion denops/skkeleton/function/henkan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ export async function henkanFirst(context: Context, key: string) {
? state.henkanFeed
: getOkuriStr(state.henkanFeed, state.okuriFeed);
state.word = word;
if (!state.directInput && ["okurinasi", "okuriari"].includes(state.mode)) {
if (
state.affix == null &&
!state.directInput &&
["okurinasi", "okuriari"].includes(state.mode)
) {
// When user maunally uses henkanPoint,
// henkanFeed like `>prefix` and `suffix>` may
// reach here without undetermined affix
state.affix = state.henkanFeed.match(">$")
? "prefix"
: state.henkanFeed.match("^>")
Expand Down
2 changes: 2 additions & 0 deletions denops/skkeleton/function/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function affix(context: Context, key: string) {
["okurinasi", "okuriari"].includes(context.state.mode)
) {
await acceptResult(context, [">", ""], "");
context.state.affix = "prefix";
await henkanFirst(context, key);
return;
}
Expand All @@ -206,6 +207,7 @@ export async function affix(context: Context, key: string) {
await kakutei(context);
henkanPoint(context);
await acceptResult(context, [">", ""], "");
context.state.affix = "suffix";
return;
}

Expand Down

0 comments on commit 1a052e0

Please sign in to comment.