From b7e4f6a878b308ee37e15c7ecd2d9aed1457c05e Mon Sep 17 00:00:00 2001 From: amzxyz Date: Tue, 6 Jan 2026 22:32:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=9C=A8=E7=A9=BA?= =?UTF-8?q?=E5=80=99=E9=80=89=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E5=80=99=E9=80=89=E7=9A=84=E6=B4=BE=E7=94=9F=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=B8=8A=E4=B8=80=E4=B8=AA=E5=AD=97?= =?UTF-8?q?=E6=98=AF=E6=B1=89=E5=AD=97=EF=BC=8C=E4=B8=94=E4=B8=89=E7=A0=81?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=A0=81=E7=9A=84=E6=97=B6=E5=80=99=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=B4=BE=E7=94=9F=E4=B8=8A=E4=B8=80=E4=B8=AA=E5=AD=97?= =?UTF-8?q?=E5=8A=A0~=E6=B3=A8=E9=87=8A=E5=A6=82=EF=BC=9Ackl=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=B4=BE=E7=94=9F=20=E6=93=8D~=20=E8=80=8Cctrl+g?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=A4=A7=E5=AD=97=E9=9B=86=E5=B0=B1=E4=BC=9A?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=8E=9F=E6=9C=AC=E7=9A=84=E8=BE=93=E5=87=BA?= =?UTF-8?q?=20=E4=8E=AD=EF=BC=8C=E8=BF=99=E5=9C=A8=E8=A7=86=E8=A7=89?= =?UTF-8?q?=E4=B8=8A=E5=BC=A5=E8=A1=A5=E4=BA=86=E7=A9=BA=E7=A0=81=E5=B8=A6?= =?UTF-8?q?=E6=9D=A5=E7=9A=84=E9=A1=BF=E6=8C=AB=E6=84=9F=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=B4=BE=E7=94=9F=E5=87=BA=E8=8B=B1=E6=96=87=E7=9A=84?= =?UTF-8?q?=E4=B8=8D=E5=90=88=E7=90=86=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/super_english.lua | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lua/super_english.lua b/lua/super_english.lua index d32411c..76f3adf 100644 --- a/lua/super_english.lua +++ b/lua/super_english.lua @@ -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)