Skip to content

Commit a313c19

Browse files
committed
修复代码错误
1 parent 45e84d2 commit a313c19

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

CodeService/src/FormatElement/AlignmentElement.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ FormatElementType AlignmentElement::GetType()
1212
return FormatElementType::AlignmentElement;
1313
}
1414

15-
void AlignmentElement::Serialize(FormatContext& ctx, std::optional<FormatElement::ChildIterator> selfIt, FormatElement& parent)
15+
void AlignmentElement::Serialize(FormatContext& ctx, std::optional<FormatElement::ChildIterator> selfIt,
16+
FormatElement& parent)
1617
{
1718
const int blank = _alignmentPosition - static_cast<int>(ctx.GetCharacterCount());
1819
if (blank > 0)
@@ -21,14 +22,15 @@ void AlignmentElement::Serialize(FormatContext& ctx, std::optional<FormatElement
2122
}
2223
}
2324

24-
void AlignmentElement::Diagnosis(DiagnosisContext& ctx, std::optional<FormatElement::ChildIterator> selfIt, FormatElement& parent)
25+
void AlignmentElement::Diagnosis(DiagnosisContext& ctx, std::optional<FormatElement::ChildIterator> selfIt,
26+
FormatElement& parent)
2527
{
26-
if(!selfIt.has_value())
28+
if (!selfIt.has_value())
2729
{
2830
return;
2931
}
30-
31-
const int nextOffset = GetNextValidOffset(selfIt.value(), parent);
32+
auto it = selfIt.value();
33+
const int nextOffset = GetNextValidOffset(it, parent);
3234
if (nextOffset == -1)
3335
{
3436
return;

CodeService/src/FormatElement/DiagnosisContext.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "Util/format.h"
44

55
DiagnosisContext::DiagnosisContext(std::shared_ptr<LuaParser> parser, LuaCodeStyleOptions& options)
6-
: _parser(parser),
7-
_options(options)
6+
: _options(options),
7+
_parser(parser)
88
{
99
}
1010

@@ -119,7 +119,7 @@ std::vector<LuaDiagnosisInfo> DiagnosisContext::GetDiagnosisInfos()
119119
if (_options.insert_final_newline && !_parser->IsEmptyLine(_parser->GetTotalLine()))
120120
{
121121
LuaDiagnosisPosition start(_parser->GetTotalLine(), _parser->GetColumn(
122-
static_cast<int>(_parser->GetSource().size())));
122+
static_cast<int>(_parser->GetSource().size())));
123123
LuaDiagnosisPosition end(_parser->GetTotalLine() + 1, 0);
124124
PushDiagnosis(LText("The code must end with a new line"), start, end);
125125
}

include/Util/format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ std::string format(std::string_view fmt, ARGS ... args)
186186
else
187187
{
188188
// 拼接字符串
189-
std:size_t replaceCount = 0;
189+
std::size_t replaceCount = 0;
190190
std::size_t start = 0;
191191
for (std::size_t index = 0; index != replaceExpresses.size(); index++)
192192
{

0 commit comments

Comments
 (0)