diff --git a/ui/keyboard/engine/index.js b/ui/keyboard/engine/index.js index 2281d65..11e556b 100644 --- a/ui/keyboard/engine/index.js +++ b/ui/keyboard/engine/index.js @@ -204,20 +204,24 @@ export class PredictionEngine { const maxDist = word.length <= 4 ? 1 : 2; const candidates = []; // Typos usually keep the first letter: search that bucket only. - this.base.forEachPrefix(word[0], MAX_CORRECTION_SCAN, (candidate, count) => { - if (Math.abs(candidate.length - word.length) > maxDist) { - return; - } - const distance = correctionDistance( - word, - candidate, - maxDist, - this.adjacency, - ); - if (distance <= maxDist) { - candidates.push({ word: candidate, count, distance }); - } - }); + this.base.forEachPrefix( + word[0], + MAX_CORRECTION_SCAN, + (candidate, count) => { + if (Math.abs(candidate.length - word.length) > maxDist) { + return; + } + const distance = correctionDistance( + word, + candidate, + maxDist, + this.adjacency, + ); + if (distance <= maxDist) { + candidates.push({ word: candidate, count, distance }); + } + }, + ); candidates.sort((a, b) => a.distance - b.distance || b.count - a.count); return candidates .slice(0, SLOTS) diff --git a/ui/keyboard/index.css b/ui/keyboard/index.css index 2f485dd..752e4b3 100644 --- a/ui/keyboard/index.css +++ b/ui/keyboard/index.css @@ -44,7 +44,11 @@ ); /* Autocorrect chip accent: primary-hued but lightened toward --kb-text so it stays high-contrast on the dark strip (not the mid-tone key-active color). */ - --kb-correction: color-mix(in oklch, var(--color-primary) 45%, var(--kb-text)); + --kb-correction: color-mix( + in oklch, + var(--color-primary) 45%, + var(--kb-text) + ); } html, diff --git a/ui/keyboard/index.js b/ui/keyboard/index.js index b31fbdf..6644505 100644 --- a/ui/keyboard/index.js +++ b/ui/keyboard/index.js @@ -127,7 +127,9 @@ async function seedContext() { const { id, layout } = TEXT_LAYOUTS[currentLayoutIndex]; // Only the letter rows are needed (autocorrect key-adjacency), and they're plain // strings, so they postMessage cleanly to the worker. - const rows = layout.lower.map((row) => row.filter((k) => typeof k === "string")); + const rows = layout.lower.map((row) => + row.filter((k) => typeof k === "string"), + ); predictor.load(id, rows); try { const ctx = await navigator.keyboard.getSurroundingText(128);