mirror of
https://github.com/d0zingcat/rime_wanxiang.git
synced 2026-05-13 15:10:03 +00:00
fix: 优化在空候选的时候中文候选的派生逻辑,如果上一个字是汉字,且三码为空码的时候自动派生上一个字加~注释如:ckl可以派生 操~ 而ctrl+g开启大字集就会恢复原本的输出 䎭,这在视觉上弥补了空码带来的顿挫感,以及派生出英文的不合理性
This commit is contained in:
@@ -234,7 +234,7 @@ function F.init(env)
|
||||
if cfg then
|
||||
delimiter_str = cfg:get_string('speller/delimiter') or delimiter_str
|
||||
end
|
||||
|
||||
env.delimiter_char = sub(delimiter_str, 1, 1) --提取自动分词符号
|
||||
local escaped_delims = gsub(delimiter_str, "([%%%^%$%(%)%%%.%[%]%*%+%-%?])", "%%%1")
|
||||
env.split_pattern = "[^" .. escaped_delims .. "]+"
|
||||
env.delim_check_pattern = "[" .. escaped_delims .. "]"
|
||||
@@ -423,17 +423,28 @@ function F.func(input, env)
|
||||
local output_text = ""
|
||||
local output_preedit = ""
|
||||
|
||||
if has_spacing then
|
||||
output_text = anchor.text .. diff
|
||||
output_preedit = (anchor.preedit or anchor.text) .. diff
|
||||
elseif last_len > 3 then
|
||||
local spacer = " "
|
||||
if sub(anchor.text, -1) == " " then spacer = "" end
|
||||
output_text = anchor.text .. spacer .. diff
|
||||
output_preedit = (anchor.preedit or anchor.text) .. spacer .. diff
|
||||
-- 英文构造策略
|
||||
if is_ascii_phrase_fast(anchor.text) then
|
||||
-- === 英文逻辑:拼接 diff,长词加空格 ===
|
||||
if has_spacing then
|
||||
output_text = anchor.text .. diff
|
||||
output_preedit = (anchor.preedit or anchor.text) .. diff
|
||||
elseif last_len > 3 then
|
||||
local spacer = " "
|
||||
if sub(anchor.text, -1) == " " then spacer = "" end
|
||||
output_text = anchor.text .. spacer .. diff
|
||||
output_preedit = (anchor.preedit or anchor.text) .. spacer .. diff
|
||||
else
|
||||
output_text = curr_input
|
||||
output_preedit = curr_input
|
||||
end
|
||||
else
|
||||
output_text = curr_input
|
||||
output_preedit = curr_input
|
||||
-- 中文逻辑:只显示历史词 (anchor),丢弃 diff
|
||||
-- 输入 nil -> anchor="你", diff="l" 注释 "~"
|
||||
output_text = anchor.text
|
||||
|
||||
-- preedit 依然保留 diff,但中间加入自动分词符号
|
||||
output_preedit = (anchor.preedit or anchor.text) .. env.delimiter_char .. diff
|
||||
end
|
||||
|
||||
output_text = apply_segment_formatting(output_text, curr_input)
|
||||
|
||||
Reference in New Issue
Block a user