Skip to content

Commit 14df130

Browse files
pro-odooLucasLefevre
authored andcommitted
[FIX] evaluation: invalidate on concurrent dropped command
Task: 4567308 Part-of: #5739 Signed-off-by: Rémi Rahir (rar) <[email protected]> Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
1 parent fb7f1e4 commit 14df130

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/model.ts

+5
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ export class Model extends EventBus<any> implements CommandDispatcher {
365365
dispatch: (command: CoreCommand) => {
366366
const result = this.checkDispatchAllowed(command);
367367
if (!result.isSuccessful) {
368+
// core views plugins need to be invalidated
369+
this.dispatchToHandlers(this.coreHandlers, {
370+
type: "UNDO",
371+
commands: [command],
372+
});
368373
return;
369374
}
370375
this.isReplayingCommand = true;

tests/collaborative/collaborative.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,22 @@ describe("Multi users synchronisation", () => {
654654
expect(getEvaluatedCell(bob, "A1", "sheet2").value).toBe(2);
655655
functionRegistry.remove("GET.ASYNC.VALUE");
656656
});
657+
658+
test("evaluation is recomputed after command is rejected because of a concurrent update", () => {
659+
createSheet(bob, { sheetId: "sheet2" });
660+
network.concurrent(() => {
661+
hideSheet(alice, "sheet2");
662+
// this command is first accepted on Charlie's side
663+
// but later rejected because there's actually only one visible sheet
664+
deleteSheet(charlie, "Sheet1");
665+
});
666+
setCellContent(charlie, "A1", "hello", "Sheet1");
667+
expect([alice, bob, charlie]).toHaveSynchronizedExportedData();
668+
expect([alice, bob, charlie]).toHaveSynchronizedValue(
669+
(user) => getEvaluatedCell(user, "A1").value,
670+
"hello"
671+
);
672+
});
657673
});
658674

659675
test("Reorder formatting rules concurrently", () => {

tests/collaborative/collaborative_history.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,18 @@ describe("Collaborative local history", () => {
918918
);
919919
});
920920

921+
test("Evaluation is the same after a sheet deletion replayed", () => {
922+
const { network, alice, bob, charlie } = setupCollaborativeEnv();
923+
setCellContent(alice, "A1", "hello");
924+
duplicateSheet(charlie, "Sheet1", "duplicateSheetId");
925+
network.concurrent(() => {
926+
hideSheet(bob, "Sheet1");
927+
deleteSheet(charlie, "Sheet1");
928+
});
929+
expect([alice, bob, charlie]).toHaveSynchronizedEvaluation();
930+
expect([alice, bob, charlie]).toHaveSynchronizedExportedData();
931+
});
932+
921933
test("transform target command with column addition before the target edge", () => {
922934
addColumns(charlie, "before", "B", 1);
923935
network.concurrent(() => {

0 commit comments

Comments
 (0)