fix(vocab): dedupe bulk import case-insensitively within the paste
Some checks failed
check / cargo check (macos-latest) (push) Has been cancelled
check / cargo check (ubuntu-22.04) (push) Has been cancelled
check / cargo check (windows-latest) (push) Has been cancelled
check / svelte build + lint (push) Has been cancelled

Previously the bulk import ran new Set(...) on raw trimmed strings
before lowercasing, so 'ACME' and 'acme' both survived the first
dedupe pass. Neither existed in the store, so both got added —
defeating the commit message's claim that pasting the same block
twice with different casing is a no-op.

Collapse case variants at the initial dedupe step using a lowercase
seen-set, keeping the first occurrence's casing as written.

Co-authored-by: jars <jakejars@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-04-21 09:18:16 +00:00
committed by Jake
parent 74062f8381
commit 0338495a57

View File

@@ -196,15 +196,19 @@
async function addBulkVocabTerms() { async function addBulkVocabTerms() {
const raw = bulkVocabText; const raw = bulkVocabText;
// Accept newline-separated OR comma-separated (or mixed) — whichever the // Accept newline-separated OR comma-separated (or mixed) — whichever the
// user pasted. Trim each entry, drop empties, dedupe within the input. // user pasted. Trim each entry, drop empties, and dedupe case-insensitively
const candidates = Array.from( // so "ACME" and "acme" in the same paste collapse to a single term
new Set( // (Whisper prompts don't care about case).
raw const seen = new Set();
.split(/[\n,]+/) const candidates = [];
.map((entry) => entry.trim()) for (const entry of raw.split(/[\n,]+/)) {
.filter((entry) => entry.length > 0), const trimmed = entry.trim();
), if (!trimmed) continue;
); const key = trimmed.toLowerCase();
if (seen.has(key)) continue;
seen.add(key);
candidates.push(trimmed);
}
if (candidates.length === 0) { if (candidates.length === 0) {
vocabularyError = "Nothing to import — paste one term per line or separated by commas."; vocabularyError = "Nothing to import — paste one term per line or separated by commas.";
return; return;