Skip to content

Commit 2fba76e

Browse files
committed
[PERF] merge: faster intersection with zone
Steps to reproduce: - add 1000 rows - copy a simple value - select a huge zone (all columns, all rows) - paste => watch your browser burn. The process never ends. closes #4225 Task: 3924969 X-original-commit: 4903083 Signed-off-by: Pierre Rousseau (pro) <[email protected]>
1 parent 5b7b84b commit 2fba76e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/plugins/core/merge.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,12 @@ export class MergePlugin extends CorePlugin<MergeState> implements MergeState {
187187
* if they have at least a common cell
188188
*/
189189
doesIntersectMerge(sheetId: UID, zone: Zone): boolean {
190-
return positions(zone).some(
191-
({ col, row }) => this.getMerge({ sheetId, col, row }) !== undefined
192-
);
190+
for (const merge of this.getMerges(sheetId)) {
191+
if (overlap(zone, merge)) {
192+
return true;
193+
}
194+
}
195+
return false;
193196
}
194197

195198
/**

0 commit comments

Comments
 (0)