Skip to content

Commit 57f36ce

Browse files
committed
Set cells with empty formulas have undefined value
1 parent ff2c006 commit 57f36ce

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/classes.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export class Sheet {
316316
this.heights.length;
317317
this.widths.length;
318318

319-
if (cell.formula == null) {
319+
if (cell.formula == null || cell.formula == "") {
320320
cell.value.rederive([], (_, set) => set(undefined));
321321
return;
322322
}

test/sheet-and-formula.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,10 @@ test("Formula functions can access `this`", async () => {
367367
const state = createSheet([["=BOLD(RC[1] + 1)", "3"]]);
368368
await expectSheet(state.currentSheet, [[4, 3]]);
369369
});
370+
371+
test("Cells with empty formula have undefined value", async () => {
372+
const state = createSheet([["", "3"]]);
373+
await expectSheet(state.currentSheet, [[undefined, 3]]);
374+
state.currentSheet.cells[0][1].formula = "";
375+
await expectSheet(state.currentSheet, [[undefined, undefined]]);
376+
});

todo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
- LINK/URL
5757
- DEBUG?
5858
- Keyboard shortcuts
59+
- Tab stays in insert mode
5960
- Navigate windows/sheets
6061
- gt and gT
6162
- i3 type key commands
@@ -104,4 +105,3 @@
104105
- The bottom border of sheet tabs do not adjust after renaming
105106
- If all sheets are deleted, it glitches
106107
- Clicking a cell in insert mode switches to normal mode
107-
- Turn the empty string back into `undefined`

0 commit comments

Comments
 (0)