diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index 323acbae9..5e387366b 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -126,6 +126,19 @@ wcstring parse_error_t::describe_with_prefix(const wcstring &src, const wcstring result.push_back(L'\n'); result.append(caret_space_line); result.push_back(L'^'); + if (source_length > 1) { + // Add a squiggle under the error location. + // We do it like this + // ^~~^ + // With a "^" under the start and end, and squiggles in-between. + auto width = fish_wcswidth(src.c_str() + source_start, source_length); + if (width > 2) { + // Subtract one for each of the carets - this is important in case + // the starting char has a width of > 1. + result.append(width - 2, L'~'); + result.push_back(L'^'); + } + } return result; }