mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 07:34:32 +00:00
Clean up a few string handling bits
This commit is contained in:
parent
446735af07
commit
d992480204
2 changed files with 6 additions and 4 deletions
|
@ -766,7 +766,7 @@ class pcre2_matcher_t : public string_matcher_t {
|
|||
(unsigned long)(end - begin));
|
||||
} else if (end > begin) {
|
||||
// May have end < begin if \K is used.
|
||||
streams.out.append(wcstring(&arg[begin], end - begin));
|
||||
streams.out.append(arg.substr(begin, end - begin));
|
||||
}
|
||||
streams.out.push_back(L'\n');
|
||||
}
|
||||
|
|
|
@ -286,15 +286,17 @@ void layout_cache_t::add_prompt_layout(wcstring input, prompt_layout_t layout) {
|
|||
|
||||
/// Calculate layout information for the given prompt. Does some clever magic to detect common
|
||||
/// escape sequences that may be embedded in a prompt, such as those to set visual attributes.
|
||||
static prompt_layout_t calc_prompt_layout(const wcstring &prompt, layout_cache_t &cache) {
|
||||
if (auto cached_layout = cache.find_prompt_layout(prompt)) {
|
||||
/// escape sequences that may be embeded in a prompt, such as those to set visual attributes.
|
||||
static prompt_layout_t calc_prompt_layout(const wcstring &prompt_str, layout_cache_t &cache) {
|
||||
if (auto cached_layout = cache.find_prompt_layout(prompt_str)) {
|
||||
return *cached_layout;
|
||||
}
|
||||
|
||||
prompt_layout_t prompt_layout = {1, 0, 0};
|
||||
size_t current_line_width = 0;
|
||||
|
||||
for (int j = 0; prompt[j]; j++) {
|
||||
const wchar_t *prompt = prompt_str.c_str();
|
||||
for (size_t j = 0; prompt[j]; j++) {
|
||||
if (prompt[j] == L'\x1B') {
|
||||
// This is the start of an escape code. Skip over it if it's at least one char long.
|
||||
size_t len = escape_code_length(&prompt[j]);
|
||||
|
|
Loading…
Reference in a new issue