Skip to content

Commit 4b983a6

Browse files
fix(named-expressions): mark named expressions as dirty before re-computation (#1504)
Fix #1501 --------- Co-authored-by: Kuba Sekowski <jakub.sekowski@handsontable.com>
1 parent 0bfd98e commit 4b983a6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/DependencyGraph/DependencyGraph.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,20 @@ export class DependencyGraph {
224224
const namedExpression = this.namedExpressions.namedExpressionOrPlaceholder(expressionName, sheetId)
225225
return this.fetchCellOrCreateEmpty(namedExpression.address)
226226
}
227-
227+
public markAllNamedExpressionsAsDirty(): void {
228+
const allExpressions = this.namedExpressions.getAllNamedExpressions();
229+
for (const { expression } of allExpressions) {
230+
const vertex = this.shrinkPossibleArrayAndGetCell(expression.address);
231+
if (vertex !== undefined) {
232+
this.graph.markNodeAsDirty(vertex);
233+
}
234+
}
235+
}
228236
public exchangeNode(addressFrom: SimpleCellAddress, addressTo: SimpleCellAddress) {
229-
const vertexFrom = this.fetchCellOrCreateEmpty(addressFrom).vertex
230-
const vertexTo = this.fetchCellOrCreateEmpty(addressTo).vertex
231-
this.addressMapping.removeCell(addressFrom)
232-
this.exchangeGraphNode(vertexFrom, vertexTo)
237+
const vertexFrom = this.fetchCellOrCreateEmpty(addressFrom).vertex;
238+
const vertexTo = this.fetchCellOrCreateEmpty(addressTo).vertex;
239+
this.addressMapping.removeCell(addressFrom);
240+
this.exchangeGraphNode(vertexFrom, vertexTo);
233241
}
234242

235243
public fetchCellOrCreateEmpty(address: SimpleCellAddress): { vertex: CellVertex, id: Maybe<number> } {

src/HyperFormula.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4503,6 +4503,7 @@ export class HyperFormula implements TypedEmitter {
45034503
const changes = this._crudOperations.getAndClearContentChanges()
45044504
const verticesToRecomputeFrom = this.dependencyGraph.verticesToRecompute()
45054505
this.dependencyGraph.clearDirtyVertices()
4506+
this.dependencyGraph.markAllNamedExpressionsAsDirty()
45064507

45074508
if (verticesToRecomputeFrom.length > 0) {
45084509
changes.addAll(this.evaluator.partialRun(verticesToRecomputeFrom))

0 commit comments

Comments
 (0)