Repository navigation
Clear sheet before removing - #1160
Conversation
Performance comparison of head (0499db9) vs base (8e0c945) |
| this.stats.measure(StatType.ADJUSTING_ARRAY_MAPPING, () => { | ||
| for (const array of arrays.values()) { | ||
| this.arrayMapping.removeArray(array.getRange()) | ||
| } | ||
| }) | ||
|
|
There was a problem hiding this comment.
This code is no longer necessary because clearSheet also removes array vertices.
adamu-handsontable
left a comment
There was a problem hiding this comment.
There are small potential improvements that we could discuss.
| expect(Array.from(engine.addressMapping.entries())).toEqual([]) | ||
| }) | ||
|
|
||
| it('should remove a sheet with a cell reference to a value in the same sheet', () => { |
There was a problem hiding this comment.
I think it could be a good idea to check if by removing one sheet, we're not affecting values in another sheet which is referenced. This does not have to be a scope of this PR, but maybe it's worth checking if it makes sense:
it('should not remove data from cell referenced in another sheet', () => {
const engine = HyperFormula.buildFromSheets({
Sheet1: [
['=Sheet2!A1)'],
],
Sheet2: [
['1'],
],
})
engine.removeSheet(0)
expect(Array.from(engine.sheetMapping.displayNames())).toEqual(['Sheet2'])
expect(engine.getCellValue(adr('A1', 1))).toBe(1)
})
it('should not remove data from cell range referenced in another sheet', () => {
const engine = HyperFormula.buildFromSheets({
Sheet1: [
['=SUM(Sheet2!A1:A2)'],
],
Sheet2: [
['1'],
['5'],
],
})
engine.removeSheet(0)
expect(Array.from(engine.sheetMapping.displayNames())).toEqual(['Sheet2'])
expect(engine.getCellValue(adr('A1', 1))).toBe(1)
expect(engine.getCellValue(adr('A2', 1))).toBe(5)
})Let me know what you think.
There was a problem hiding this comment.
Sure, these test cases are absolutely valid. I added an it that covers both of them
Codecov Report
@@ Coverage Diff @@
## develop #1160 +/- ##
===========================================
- Coverage 95.84% 95.84% -0.01%
===========================================
Files 165 165
Lines 14144 14135 -9
Branches 3007 3004 -3
===========================================
- Hits 13556 13547 -9
Misses 588 588
|
adamu-handsontable
left a comment
There was a problem hiding this comment.
Everything is good. Thank you
How did you test your changes?
Types of changes
Related issues:
Fixes #1121
Checklist: