MCPcopy Create free account
hub / github.com/Koihik/LuaFormatter / handleLineSeparator

Function handleLineSeparator

src/lua-format.cpp:64–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64std::string handleLineSeparator(const std::string& original, const std::string& formatted, const Config& config) {
65 const auto line_separator_config = config.get<std::string>("line_separator");
66 auto out = formatted;
67 if (line_separator_config == "os") {
68 out = convert_line_separator(out, getOSLineSeparator());
69 } else if (line_separator_config == "input") {
70 auto line_sep = get_line_separator(original);
71 out = convert_line_separator(out, line_sep);
72 } else if (line_separator_config == "lf") {
73 out = convert_line_separator(out, "\n");
74 } else if (line_separator_config == "cr") {
75 out = convert_line_separator(out, "\r");
76 } else if (line_separator_config == "crlf") {
77 out = convert_line_separator(out, "\r\n");
78 } else {
79 throw std::runtime_error("Should not reach here. Invalid line_separator config");
80 }
81 return out;
82}
83
84std::string resetContentInDisableFormatBlocks(const std::string& original, const std::string& formatted) {
85 std::vector<std::pair<size_t, size_t>> originalBlocks = findBlocksBetweenFormatSwitch(original);

Callers 1

lua_formatFunction · 0.85

Calls 3

convert_line_separatorFunction · 0.85
getOSLineSeparatorFunction · 0.85
get_line_separatorFunction · 0.85

Tested by

no test coverage detected