Skip to content

fix(trie): delete words containing supplementary Unicode characters - #2239

Open
Shubham-Padkonde wants to merge 1 commit into
trekhleb:masterfrom
Shubham-Padkonde:fix/trie-delete-unicode
Open

Shubham-Padkonde wants to merge 1 commit into
trekhleb:masterfrom
Shubham-Padkonde:fix/trie-delete-unicode

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

Deleting a word containing a supplementary Unicode character currently leaves it in the trie. Insertion and lookup iterate code points, but deletion indexes UTF-16 code units and cannot find the corresponding child.

Use Array.from(word) consistently during deletion. The regression covers emoji at the start and end of words, shared prefixes, a non-emoji supplementary character, a missing word, and cleanup after all words are deleted. It fails before the fix.

Fixes #2237.

Validation: npm run lint and the complete Jest coverage suite pass. Trie.js retains 100% statement, branch, function, and line coverage.

AI-assisted contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trie.deleteWord fails for words containing characters outside the BMP (e.g. emoji)

1 participant