@@ -160,12 +160,12 @@ void LuaTypeFormat::AnalysisReturn(int line, int character)
160160
161161 if (_typeOptions.format_line )
162162 {
163- FormatLine (line);
163+ FormatLine (line, character );
164164 }
165165
166- if (_typeOptions.fix_indent ) {
167- FixIndent (line, character);
168- }
166+ // if (_typeOptions.fix_indent) {
167+ // FixIndent(line, character);
168+ // }
169169}
170170
171171void LuaTypeFormat::CompleteMissToken (int line, int character, LuaError& luaError)
@@ -280,8 +280,21 @@ void LuaTypeFormat::CompleteMissToken(int line, int character, LuaError& luaErro
280280 }
281281}
282282
283- void LuaTypeFormat::FormatLine (int line)
283+ void LuaTypeFormat::FormatLine (int line, int character )
284284{
285+ auto luaFile = _parser->GetLuaFile ();
286+ auto offset = luaFile->GetOffsetFromPosition (line, character);
287+ auto & tokens = _parser->GetTokenParser ()->GetTokens ();
288+ auto tokenIndex = FindTokenIndexAfterPosition (tokens, offset);
289+ if (tokenIndex != -1 )
290+ {
291+ auto & token = tokens[tokenIndex];
292+ if (token.TokenType == TK_STRING || token.TokenType == TK_LONG_COMMENT)
293+ {
294+ return ;
295+ }
296+ }
297+
285298 LuaCodeStyleOptions temp = _options;
286299 temp.insert_final_newline = true ;
287300 temp.remove_expression_list_finish_comma = false ;
@@ -326,7 +339,7 @@ void LuaTypeFormat::FormatLine(int line)
326339
327340void LuaTypeFormat::FixIndent (int line, int character)
328341{
329- // FixEndIndent(line, character);
342+ FixEndIndent (line, character);
330343
331344 // auto root = _parser->GetAst();
332345 // auto astNode = FindAstNodeBeforePosition(root, offset);
0 commit comments