Skip to content

Commit 8edb5af

Browse files
committed
Fix adding newline at the end
mesonbuild/vscode-meson#273
1 parent a4a2ea1 commit 8edb5af

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/liblangserver/formatting.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ std::string formatFile(const std::filesystem::path &path,
3535
struct source src = {.label = labelPath,
3636
.src = strdup(toFormat.data()),
3737
.len = toFormat.size(),
38-
.reopen_type = source_reopen_type_none};
38+
.type = source_type_unknown};
3939
#ifndef _WIN32
4040
char *formattedStr;
4141
size_t formattedSize;

src/liblangserver/langserver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void printGreeting() {
102102

103103
std::filesystem::path writeMuonConfigFile(FormattingOptions options) {
104104
const auto &name =
105-
std::format("muon-2-fmt-{}-{}", options.insertSpaces, options.tabSize);
105+
std::format("muon-2-fmt-{}-{}-{}", options.insertSpaces, options.tabSize, options.insertFinalNewline);
106106
const auto &fullPath = cacheDir() / name;
107107
if (std::filesystem::exists(fullPath)) {
108108
return fullPath;

src/liblsptypes/lsptypes.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#pragma once
22
#include <cassert>
33
#include <cstdint>
4+
#include <iostream>
45
#include <map>
56
#include <nlohmann/json.hpp>
67
#include <optional>
8+
#include <ostream>
79
#include <string>
810
#include <utility>
911
#include <vector>
@@ -473,7 +475,7 @@ class FormattingOptions : public BaseObject {
473475
explicit FormattingOptions(nlohmann::json &jsonObj) {
474476
this->tabSize = jsonObj["tabSize"];
475477
this->insertSpaces = jsonObj["insertSpaces"];
476-
this->insertFinalNewline = jsonObj.value("insertFinalNewline", false);
478+
this->insertFinalNewline = jsonObj.value("insertFin alNewline", true);
477479
}
478480
};
479481

0 commit comments

Comments
 (0)