fix(sheets): fix the issue of double-clicking automatically filling boundaries (#6448)

This commit is contained in:
wpxp123456
2026-01-09 14:38:01 +08:00
committed by GitHub
parent eb57767b59
commit 21e2e3af2a
@@ -275,24 +275,23 @@ export class AutoFillController extends Disposable {
return source;
}
const matrix = worksheet.getCellMatrix();
const maxRow = worksheet.getMaxRows() - 1;
const maxColumn = worksheet.getMaxColumns() - 1;
let detectEndRow = endRow;
const maxRow = worksheet.getMaxRows();
const maxColumn = worksheet.getMaxColumns();
let detectEndRow = endRow + 1;
// left column first, or consider right column.
if (startColumn > 0 && matrix.getValue(startRow, startColumn - 1)?.v != null) {
let cur = startRow;
while (matrix.getValue(cur, startColumn - 1)?.v != null && cur < maxRow) {
cur += 1;
if (startColumn > 0 && matrix.getValue(detectEndRow, startColumn - 1)?.v != null) {
while (matrix.getValue(detectEndRow + 1, startColumn - 1)?.v != null && detectEndRow < maxRow) {
detectEndRow += 1;
}
detectEndRow = cur - 1;
} else if (endColumn < maxColumn && matrix.getValue(endRow, endColumn + 1)?.v != null) {
let cur = startRow;
while (matrix.getValue(cur, endColumn + 1)?.v != null && cur < maxRow) {
cur += 1;
} else if (endColumn < maxColumn - 1 && matrix.getValue(detectEndRow, endColumn + 1)?.v != null) {
while (matrix.getValue(detectEndRow + 1, endColumn + 1)?.v != null && detectEndRow < maxRow) {
detectEndRow += 1;
}
detectEndRow = cur - 1;
} else {
detectEndRow = endRow;
}
// If the fill range contains data, stop filling at the first row of data.
for (let i = endRow + 1; i <= detectEndRow; i++) {
for (let j = startColumn; j <= endColumn; j++) {
if (matrix.getValue(i, j)?.v != null) {