@@ -219,9 +219,9 @@ int type_format(lua_State *L) {
219219 }
220220 }
221221 auto typeFormatResult = LuaCodeFormat::GetInstance ()
222- .TypeFormat (filename,
223- static_cast <std::size_t >(line), static_cast <std::size_t >(character),
224- std::move (text), configMap, stringTypeOptions);
222+ .TypeFormat (filename,
223+ static_cast <std::size_t >(line), static_cast <std::size_t >(character),
224+ std::move (text), configMap, stringTypeOptions);
225225
226226 if (typeFormatResult.Type == ResultType::Err) {
227227 lua_pushboolean (L, false );
@@ -576,37 +576,37 @@ int spell_analysis(lua_State *L) {
576576 return 0 ;
577577}
578578
579- InfoNode CreateFromLua (InfoTree &t, lua_State *L, int idx ) {
580- if (lua_istable (L, idx )) {
579+ InfoNode CreateFromLua (InfoTree &t, lua_State *L) {
580+ if (lua_istable (L, - 1 )) {
581581 // lua 不区分 数组和table, 太难了
582- auto len = luaL_len (L, idx );
582+ auto len = luaL_len (L, - 1 );
583583 if (len != 0 ) {
584584 auto arr = t.CreateArray ();
585585 for (auto i = 0 ; i < len; i++) {
586- if (lua_geti (L, idx , i)) {
587- arr.AddChild (CreateFromLua (t, L, - 1 ));
586+ if (lua_geti (L, - 1 , i)) {
587+ arr.AddChild (CreateFromLua (t, L));
588588 }
589589 lua_pop (L, 1 );
590590 }
591591 return arr;
592592 } else {
593593 auto object = t.CreateObject ();
594594 lua_pushnil (L);
595- while (lua_next (L, idx ) != 0 ) {
595+ while (lua_next (L, - 2 ) != 0 ) {
596596 if (lua_isstring (L, -2 )) {
597597 auto key = luaToString (L, -2 );
598- object.AddChild (key, CreateFromLua (t, L, - 1 ));
598+ object.AddChild (key, CreateFromLua (t, L));
599599 }
600600 lua_pop (L, 1 );
601601 }
602602 return object;
603603 }
604- } else if (lua_isnumber (L, idx )) {
605- return t.CreateNumber (lua_tonumber (L, idx ));
606- } else if (lua_isstring (L, idx )) {
607- return t.CreateString (lua_tostring (L, idx ));
608- } else if (lua_isboolean (L, idx )) {
609- return t.CreateBool (lua_toboolean (L, idx ));
604+ } else if (lua_isnumber (L, - 1 )) {
605+ return t.CreateNumber (lua_tonumber (L, - 1 ));
606+ } else if (lua_isstring (L, - 1 )) {
607+ return t.CreateString (lua_tostring (L, - 1 ));
608+ } else if (lua_isboolean (L, - 1 )) {
609+ return t.CreateBool (lua_toboolean (L, - 1 ));
610610 } else {
611611 return t.CreateNone ();
612612 }
@@ -627,7 +627,7 @@ int update_name_style_config(lua_State *L) {
627627 while (lua_next (L, -2 ) != 0 ) {
628628 if (lua_isstring (L, -2 )) {
629629 auto key = luaToString (L, -2 );
630- root.AddChild (key, CreateFromLua (tree, L, - 1 ));
630+ root.AddChild (key, CreateFromLua (tree, L));
631631 }
632632 lua_pop (L, 1 );
633633 }
@@ -719,20 +719,20 @@ int spell_suggest(lua_State *L) {
719719}
720720
721721static const luaL_Reg lib[] = {
722- {" format" , format},
723- {" range_format" , range_format},
724- {" type_format" , type_format},
725- {" update_config" , update_config},
726- {" diagnose_file" , diagnose_file},
727- {" set_default_config" , set_default_config},
728- {" spell_load_dictionary_from_path" , spell_load_dictionary_from_path},
722+ {" format" , format },
723+ {" range_format" , range_format },
724+ {" type_format" , type_format },
725+ {" update_config" , update_config },
726+ {" diagnose_file" , diagnose_file },
727+ {" set_default_config" , set_default_config },
728+ {" spell_load_dictionary_from_path" , spell_load_dictionary_from_path },
729729 {" spell_load_dictionary_from_buffer" , spell_load_dictionary_from_buffer},
730- {" spell_analysis" , spell_analysis},
731- {" spell_suggest" , spell_suggest},
732- {" set_nonstandard_symbol" , set_nonstandard_symbol},
733- {" name_style_analysis" , name_style_analysis},
734- {" update_name_style_config" , update_name_style_config},
735- {nullptr , nullptr }
730+ {" spell_analysis" , spell_analysis },
731+ {" spell_suggest" , spell_suggest },
732+ {" set_nonstandard_symbol" , set_nonstandard_symbol },
733+ {" name_style_analysis" , name_style_analysis },
734+ {" update_name_style_config" , update_name_style_config },
735+ {nullptr , nullptr }
736736};
737737
738738extern " C" EXPORT int luaopen_code_format (lua_State *L) {
0 commit comments