summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorRasmusNylander <43042651+rasmusnylander@users.noreply.github.com>2021-12-15 14:48:35 +0100
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-12-16 02:44:37 +0330
commitfa991255712c5252e16aee20321646ea32acd5f4 (patch)
tree440b1171e6d2dab30712fc5f07aca0b7a514bd56 /Userland/Applications
parentc2df6b597a1add56345c49ca5bada625a77d563c (diff)
downloadserenity-fa991255712c5252e16aee20321646ea32acd5f4.zip
Spreadsheet: Handle emptying of cell containing only an '='
Cell::set_data(String new_data) now checks whether the cell is a formula-cell and the new_data is an empty string. If this is case, it will no longer simply return and will now instead actually set the cell's contents to an empty string. This fixes an error whereupon committing the string "=" to a cell, it would not be possible to directly delete the cell's contents. Instead, it first had to be overwritten with another string, which then could be deleted. This could probably be done more elegantly. Right now, I believe, writing the string "=" to a (formula-)cell already containing an identical string will result in the cell being marked as dirty, even though nothing actually changed.
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Spreadsheet/Cell.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp
index 176887eb3b..9a1a4816c2 100644
--- a/Userland/Applications/Spreadsheet/Cell.cpp
+++ b/Userland/Applications/Spreadsheet/Cell.cpp
@@ -13,6 +13,12 @@ namespace Spreadsheet {
void Cell::set_data(String new_data)
{
+ // If we are a formula, we do not save the beginning '=', if the new_data is "" we can simply change our kind
+ if (m_kind == Formula && m_data.is_empty() && new_data.is_empty()) {
+ m_kind = LiteralString;
+ return;
+ }
+
if (m_data == new_data)
return;