Skip to content

Commit 13ccea5

Browse files
committed
workaround typeformat
1 parent 72b557d commit 13ccea5

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

CodeFormatServer/src/LanguageService.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,26 @@ std::shared_ptr<vscode::Serializable> LanguageService::OnTypeFormatting(
341341
auto formatResult = LanguageClient::GetInstance().GetService<CodeFormatService>()->RangeFormat(
342342
formattedRange, parser, tempOptions);
343343

344-
344+
// workaround TODO 实现真正的typeformat
345+
if (!formatResult.ends_with('\n'))
346+
{
347+
switch (options->end_of_line)
348+
{
349+
case EndOfLine::CRLF:
350+
{
351+
formatResult.append("\r\n");
352+
break;
353+
}
354+
case EndOfLine::LF:
355+
{
356+
formatResult.push_back('\n');
357+
}
358+
default:
359+
{
360+
break;
361+
}
362+
}
363+
}
345364
auto& edit = result->edits.emplace_back();
346365
edit.newText = std::move(formatResult);
347366
edit.range = vscode::Range(
@@ -486,7 +505,6 @@ std::shared_ptr<vscode::DocumentDiagnosticReport> LanguageService::OnTextDocumen
486505
std::shared_ptr<vscode::WorkspaceDiagnosticReport> LanguageService::OnWorkspaceDiagnostic(
487506
std::shared_ptr<vscode::WorkspaceDiagnosticParams> param)
488507
{
489-
490508
// if(param->previousResultIds.empty())
491509
// {
492510
// LanguageClient::GetInstance().LoadWorkspace();

0 commit comments

Comments
 (0)