formatter: initial and basic indentation/alignment and expose the formatting via the LSP (#2673)

This commit is contained in:
Tyler Wilding
2023-05-28 12:22:00 -05:00
committed by GitHub
parent ad0b3297ca
commit 4c6982b0ec
22 changed files with 447 additions and 166 deletions
+18
View File
@@ -121,4 +121,22 @@ std::string uuid() {
}
return res;
}
std::string repeat(size_t n, const std::string& str) {
if (n == 0 || str.empty())
return {};
if (n == 1)
return str;
const auto period = str.size();
if (period == 1)
return std::string(n, str.front());
std::string ret(str);
ret.reserve(period * n);
std::size_t m{2};
for (; m < n; m *= 2)
ret += ret;
ret.append(ret.c_str(), (n - (m / 2)) * period);
return ret;
}
} // namespace str_util