diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index a0175e9aa2..e42cd6a2e9 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -98,6 +98,9 @@ static Optional convert_from_string(StringView str, unsigned base = 26, VERIFY(base >= 2 && base <= map.length()); + if (str.is_empty()) + return {}; + size_t value = 0; auto const len = str.length(); for (auto i = 0u; i < len; i++) { @@ -105,13 +108,10 @@ static Optional convert_from_string(StringView str, unsigned base = 26, if (!maybe_index.has_value()) return {}; size_t digit_value = maybe_index.value(); - // NOTE: Refer to the note in `String::bijective_base_from()'. - if (i == 0 && len > 1) - ++digit_value; - value += digit_value * AK::pow(base, len - 1 - i); + value += (digit_value + 1) * AK::pow(base, len - 1 - i); } - return value; + return value - 1; } DeprecatedString Sheet::add_column()