From 8939a71ec6ee4b07bea1b8d743e0f06daee9dfa1 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 27 Jul 2021 20:11:32 +0200 Subject: [PATCH] An empty string means we're on the first line Oops, this broke up-or-search! --- src/parse_util.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/parse_util.cpp b/src/parse_util.cpp index 427c20043..be5a8e5eb 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -44,7 +44,9 @@ static constexpr int var_err_len = 16; int parse_util_lineno(const wcstring &str, size_t offset) { // 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; return std::count(str.begin(), end, L'\n') + 1;