fix(engine): 辅助码串上的 Ctrl+方向与 Ctrl+Backspace 按单元编辑 (#627)

双拼串里带句中辅助码(反引号段 / 大写段)或开着直接辅助码时,segment_raw_boundaries
直接返回空,Server 只能退回逐字符移动和删除。

现在按请求带着的辅助码段布局切单元:每个音节和挂在它后面的辅码段各算一个单元,
Ctrl+Backspace 可以只删辅码,Ctrl+方向也能停在音节与辅码之间。布局对不上原串时仍
不给边界、退回逐字符。直接辅助码没解析出辅码时请求原样放行,沿用普通双拼切分。

光标前缀重算与按段编辑共用同一套边界,带辅助码的串也随之按光标前缀出候选。
This commit is contained in:
Lu Fan(SonnyCalcr) authored and GitHub committed 2026-10-05 04:19:23 +08:00
1 parent b391fd616b
commit 1da1c1bcd6
4 files changed
+102 -5

No files matched your search

@@ -258,6 +258,9 @@ void run_session_tests()
on->candidates().size() == off->candidates().size(),
"Plain shuangpin changed when direct helpcode was turned on.");
require(on->get_pinyin_sequence() == "uiui", "Plain shuangpin was rewritten by the resolver.");
require(on->segment_raw_boundaries() == std::vector<std::size_t>({0, 2, 4}) &&
on->segment_raw_boundaries() == off->segment_raw_boundaries(),
"Plain shuangpin lost its unit boundaries when direct helpcode was turned on.");
}
{
@@ -272,6 +275,9 @@ void run_session_tests()
require(session->get_pinyin_sequence() == "ui'ui", "The resolver did not strip the helpcode letters.");
require(session->get_pinyin_segmentation_with_cases() == "uia'uiq",
"The helpcode letters were not shown after their syllables.");
// 按段删除 / 跳光标的单元:每个音节和它后面的辅码各算一个。
require(session->segment_raw_boundaries() == std::vector<std::size_t>({0, 2, 3, 5, 6}),
"The direct helpcode letters were not units of their own.");
}
{
@@ -311,6 +317,8 @@ void run_session_tests()
require(first_word(*session) == "石狮", "uiab/ui did not keep 石 on the first syllable.");
require(session->get_pinyin_segmentation_with_cases() == "uiab/'ui",
"The four-key code and its slash were not shown after their syllable.");
require(session->segment_raw_boundaries() == std::vector<std::size_t>({0, 2, 5, 7}),
"The four-key code and its slash were not one unit.");
}
{