mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-14 16:41:15 -03:00
Make { and } valid, first-class tokenizer elements
This commit is contained in:
@@ -45,3 +45,21 @@ wcstring truncate(const wcstring &input, int max_len, ellipsis_type etype) {
|
||||
output.push_back(ellipsis_char);
|
||||
return output;
|
||||
}
|
||||
|
||||
wcstring trim(const wcstring &input) {
|
||||
debug(0, "trimming '%ls'", input.c_str());
|
||||
|
||||
// auto begin = input.cbegin();
|
||||
// for (begin; *begin == L' '; ++begin);
|
||||
// auto end = input.cbegin() + input.size();
|
||||
// for (end; end > begin && *end == L' '; ++end);
|
||||
|
||||
auto begin_offset = input.find_first_not_of(whitespace);
|
||||
if (begin_offset == wcstring::npos) {
|
||||
return wcstring{};
|
||||
}
|
||||
auto end = input.cbegin() + input.find_last_not_of(whitespace);
|
||||
|
||||
wcstring result(input.begin() + begin_offset, end + 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user