Skip to content

Fix incorrect pinyin highlight for polyphonic characters (e.g. 核查 with hecha/heia) - #4607

Draft
VictoriousRaptor with Copilot wants to merge 2 commits into
devfrom
copilot/fix-incorrect-highlight-pinyin
Draft

Fix incorrect pinyin highlight for polyphonic characters (e.g. 核查 with hecha/heia)#4607
VictoriousRaptor with Copilot wants to merge 2 commits into
devfrom
copilot/fix-incorrect-highlight-pinyin

Conversation

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Searching for 核查 using full pinyin (hecha) or XiaoHe double pinyin (heia) produced no highlights because the ToolGood library's GetPinyinList() applies context-sensitive disambiguation across the whole input string — incorrectly returning "Zha" for in "核查" instead of "Cha". This caused the translated form to be "He Zha" / "he va" (XiaoHe), which doesn't match the user's query.

Changes

  • PinyinAlphabet.csBuildCacheFromContent: Replace bulk WordsHelper.GetPinyinList(content) with per-character WordsHelper.GetAllPinyin(c, false)[0], which returns pronunciations sorted by frequency and avoids erroneous cross-character disambiguation.
// Before — wrong: GetPinyinList("核查") → ["He", "Zha"]
var resultList = WordsHelper.GetPinyinList(content);
var translated = _settings.UseDoublePinyin ? ToDoublePinyin(resultList[i]) : resultList[i];

// After — correct: GetAllPinyin('查') → ["Cha", "Zha"] → uses "Cha"
var allPinyins = WordsHelper.GetAllPinyin(content[i], false);
var pinyin = allPinyins.Count > 0 ? allPinyins[0] : WordsHelper.GetPinyinList(content[i].ToString(), false)[0];
var translated = _settings.UseDoublePinyin ? ToDoublePinyin(pinyin) : pinyin;

With the fix, 核查 translates to "He Cha" (full pinyin) / "he ia" (XiaoHe), correctly matching and highlighting both characters.

…d of bulk GetPinyinList

The ToolGood library's GetPinyinList() performs context-sensitive disambiguation
that can produce incorrect pinyin for some characters. For example, '查' in '核查'
was incorrectly returned as 'Zha' instead of 'Cha', causing both full-pinyin
("hecha") and double-pinyin ("heia" in XiaoHe) searches to fail to highlight
the matched characters.

Fix: Use WordsHelper.GetAllPinyin() per character, which returns pronunciations
sorted by frequency (most common first), avoiding incorrect context-sensitive
disambiguation.

Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incorrect highlight when using pinyin in Flow Launcher Fix incorrect pinyin highlight for polyphonic characters (e.g. 核查 with hecha/heia) Aug 6, 2026
Copilot AI requested a review from VictoriousRaptor August 6, 2026 07:26

@Jack251970 Jack251970 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can continue this work in #4544 instead of this new PR.

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.

BUG: Incorrect highlight when using pinyin in some cases

3 participants