mirror of
https://github.com/open-goal/jak-project
synced 2026-06-01 09:48:00 -04:00
formatter: initial and basic indentation/alignment and expose the formatting via the LSP (#2673)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user