mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-30 23:51:15 -03:00
Factor out count_preceding_backslashes
Now that we have multiple clients of count_preceding_backslashes, factor it out from fish_indent into wcstringutil.h, and then use the shared implementation.
This commit is contained in:
@@ -74,6 +74,15 @@ wcstring wcstolower(wcstring input) {
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t count_preceding_backslashes(const wcstring &text, size_t idx) {
|
||||
assert(idx <= text.size() && "Out of bounds");
|
||||
size_t backslashes = 0;
|
||||
while (backslashes < idx && text.at(idx - backslashes - 1) == L'\\') {
|
||||
backslashes++;
|
||||
}
|
||||
return backslashes;
|
||||
}
|
||||
|
||||
bool string_prefixes_string(const wchar_t *proposed_prefix, const wcstring &value) {
|
||||
return string_prefixes_string(proposed_prefix, value.c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user