mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
An empty string means we're on the first line
Oops, this broke up-or-search!
This commit is contained in:
parent
48e696bbb4
commit
8939a71ec6
1 changed files with 3 additions and 1 deletions
|
@ -44,7 +44,9 @@ static constexpr int var_err_len = 16;
|
||||||
|
|
||||||
int parse_util_lineno(const wcstring &str, size_t offset) {
|
int parse_util_lineno(const wcstring &str, size_t offset) {
|
||||||
// Return the line number of position offset, starting with 1.
|
// Return the line number of position offset, starting with 1.
|
||||||
if (str.empty()) return 0;
|
if (str.empty()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
auto end = offset > str.length() ? str.end() : str.begin() + offset;
|
auto end = offset > str.length() ? str.end() : str.begin() + offset;
|
||||||
return std::count(str.begin(), end, L'\n') + 1;
|
return std::count(str.begin(), end, L'\n') + 1;
|
||||||
|
|
Loading…
Reference in a new issue