From 48789c26d9dd809329d57065baabc0053009f540 Mon Sep 17 00:00:00 2001 From: cccc <132337734+2725244134@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:15:11 +0800 Subject: [PATCH] fix(lua): avoid assigning to const for-loop variable for Lua 5.5 compat (#1517) follow 18cb213d9f9da76ac58dae67fc428220889e370e --- lua/cn_en_spacer.lua | 7 ++++--- lua/en_spacer.lua | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lua/cn_en_spacer.lua b/lua/cn_en_spacer.lua index 37771a0..acbb9b5 100644 --- a/lua/cn_en_spacer.lua +++ b/lua/cn_en_spacer.lua @@ -21,10 +21,11 @@ end local function cn_en_spacer(input, env) for cand in input:iter() do - if is_mixed_cn_en_num(cand.text) then - cand = cand:to_shadow_candidate(cand.type, add_spaces(cand.text), cand.comment) + local c = cand + if is_mixed_cn_en_num(c.text) then + c = c:to_shadow_candidate(c.type, add_spaces(c.text), c.comment) end - yield(cand) + yield(c) end end diff --git a/lua/en_spacer.lua b/lua/en_spacer.lua index 827f05f..7a46888 100644 --- a/lua/en_spacer.lua +++ b/lua/en_spacer.lua @@ -6,11 +6,12 @@ local F = {} function F.func( input, env ) local latest_text = env.engine.context.commit_history:latest_text() for cand in input:iter() do - if cand.text:match( '^[%a\']+[%a\']*$' ) and latest_text and #latest_text > 0 and + local c = cand + if c.text:match( '^[%a\']+[%a\']*$' ) and latest_text and #latest_text > 0 and latest_text:find( '^ ?[%a\']+[%a\']*$' ) then - cand = cand:to_shadow_candidate( 'en_spacer', cand.text:gsub( '(%a+\'?%a*)', ' %1' ), cand.comment ) + c = c:to_shadow_candidate( 'en_spacer', c.text:gsub( '(%a+\'?%a*)', ' %1' ), c.comment ) end - yield( cand ) + yield( c ) end end