Skip to content

Commit bb4cdbc

Browse files
committed
fix sumneko_1919
1 parent 0123369 commit bb4cdbc

File tree

1 file changed

+50
-48
lines changed

1 file changed

+50
-48
lines changed

CodeFormatLib/src/CodeFormatLib.cpp

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -223,58 +223,60 @@ int type_format(lua_State *L) {
223223
if (typeFormatResult.Type == ResultType::Err) {
224224
lua_pushboolean(L, false);
225225
return 1;
226-
} else {
227-
lua_pushboolean(L, true);
228-
auto &typeFormats = typeFormatResult.Data;
229-
if (!typeFormats.empty()) {
230-
auto &result = typeFormats.front();
231-
// 结果
232-
lua_newtable(L);
233-
234-
//message
235-
{
236-
lua_pushstring(L, "newText");
237-
lua_pushlstring(L, result.Text.c_str(), result.Text.size());
238-
lua_rawset(L, -3);
239-
}
226+
}
227+
auto &typeFormats = typeFormatResult.Data;
228+
if (typeFormats.empty()) {
229+
lua_pushboolean(L, false);
230+
return 1;
231+
}
232+
233+
lua_pushboolean(L, true);
234+
auto &result = typeFormats.front();
235+
// 结果
236+
lua_newtable(L);
240237

241-
// range
242-
{
243-
lua_pushstring(L, "range");
244-
//range table
245-
lua_newtable(L);
238+
//message
239+
{
240+
lua_pushstring(L, "newText");
241+
lua_pushlstring(L, result.Text.c_str(), result.Text.size());
242+
lua_rawset(L, -3);
243+
}
246244

247-
lua_pushstring(L, "start");
248-
// start table
249-
lua_newtable(L);
250-
lua_pushstring(L, "line");
251-
lua_pushinteger(L, result.Range.StartLine);
252-
lua_rawset(L, -3);
245+
// range
246+
{
247+
lua_pushstring(L, "range");
248+
//range table
249+
lua_newtable(L);
253250

254-
lua_pushstring(L, "character");
255-
lua_pushinteger(L, result.Range.StartCol);
256-
lua_rawset(L, -3);
251+
lua_pushstring(L, "start");
252+
// start table
253+
lua_newtable(L);
254+
lua_pushstring(L, "line");
255+
lua_pushinteger(L, result.Range.StartLine);
256+
lua_rawset(L, -3);
257257

258-
lua_rawset(L, -3); // set start = {}
258+
lua_pushstring(L, "character");
259+
lua_pushinteger(L, result.Range.StartCol);
260+
lua_rawset(L, -3);
259261

260-
lua_pushstring(L, "end");
261-
// end table
262-
lua_newtable(L);
263-
lua_pushstring(L, "line");
264-
lua_pushinteger(L, result.Range.EndLine);
265-
lua_rawset(L, -3);
262+
lua_rawset(L, -3); // set start = {}
266263

267-
lua_pushstring(L, "character");
268-
lua_pushinteger(L, result.Range.EndCol);
269-
lua_rawset(L, -3);
264+
lua_pushstring(L, "end");
265+
// end table
266+
lua_newtable(L);
267+
lua_pushstring(L, "line");
268+
lua_pushinteger(L, result.Range.EndLine);
269+
lua_rawset(L, -3);
270270

271-
lua_rawset(L, -3); // set end = {}
271+
lua_pushstring(L, "character");
272+
lua_pushinteger(L, result.Range.EndCol);
273+
lua_rawset(L, -3);
272274

273-
lua_rawset(L, -3); // set range = {}
274-
}
275-
}
276-
return 2;
275+
lua_rawset(L, -3); // set end = {}
276+
277+
lua_rawset(L, -3); // set range = {}
277278
}
279+
return 2;
278280
}
279281
catch (std::exception &e) {
280282
std::string err = e.what();
@@ -403,7 +405,7 @@ int diagnose_file(lua_State *L) {
403405
return 1;
404406
}
405407

406-
auto& diagnostics = diagnosticResult.Data;
408+
auto &diagnostics = diagnosticResult.Data;
407409
lua_pushboolean(L, true);
408410
PushDiagnosticToLua(L, diagnostics);
409411

@@ -557,12 +559,12 @@ int spell_analysis(lua_State *L) {
557559
}
558560

559561
auto spellResult = LuaCodeFormat::GetInstance().SpellCheck(filename, std::move(text), tempDict);
560-
if(spellResult.Type == ResultType::Err){
562+
if (spellResult.Type == ResultType::Err) {
561563
lua_pushboolean(L, false);
562564
return 1;
563565
}
564566

565-
auto& diagnostics = spellResult.Data;
567+
auto &diagnostics = spellResult.Data;
566568
lua_pushboolean(L, true);
567569
PushDiagnosticToLua(L, diagnostics);
568570

@@ -592,12 +594,12 @@ int name_style_analysis(lua_State *L) {
592594
std::string text = lua_tostring(L, 2);
593595

594596
auto nameStyleResult = LuaCodeFormat::GetInstance().NameStyleCheck(filename, std::move(text));
595-
if(nameStyleResult.Type == ResultType::Err){
597+
if (nameStyleResult.Type == ResultType::Err) {
596598
lua_pushboolean(L, false);
597599
return 1;
598600
}
599601

600-
auto& diagnostics = nameStyleResult.Data;
602+
auto &diagnostics = nameStyleResult.Data;
601603
lua_pushboolean(L, true);
602604
PushDiagnosticToLua(L, diagnostics);
603605

0 commit comments

Comments
 (0)