FIX: Apply copilot suggestions
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
9852ce2504
commit
266c14d5d2
@@ -1603,7 +1603,7 @@ impl UserModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the largest column in the row less than a column whose cell has a non empty value.
|
/// Returns the largest column in the row less than a column whose cell has a non empty value.
|
||||||
/// If the row is empty, it returns `None`.
|
/// If there are none it returns `None`.
|
||||||
/// This is useful when rendering a part of a worksheet to know which cells spill over
|
/// This is useful when rendering a part of a worksheet to know which cells spill over
|
||||||
pub fn get_last_non_empty_in_row_before_column(
|
pub fn get_last_non_empty_in_row_before_column(
|
||||||
&self,
|
&self,
|
||||||
@@ -1633,7 +1633,9 @@ impl UserModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the largest column in the row greater than a column whose cell has a non empty value.
|
/// Returns the smallest column in the row larger than "column" whose cell has a non empty value.
|
||||||
|
/// If there are none it returns `None`.
|
||||||
|
/// This is useful when rendering a part of a worksheet to know which cells spill over
|
||||||
pub fn get_first_non_empty_in_row_after_column(
|
pub fn get_first_non_empty_in_row_after_column(
|
||||||
&self,
|
&self,
|
||||||
sheet: u32,
|
sheet: u32,
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ export const defaultCellFontFamily = fonts.regular;
|
|||||||
export const headerFontFamily = fonts.regular;
|
export const headerFontFamily = fonts.regular;
|
||||||
export const frozenSeparatorWidth = 3;
|
export const frozenSeparatorWidth = 3;
|
||||||
|
|
||||||
type Tuple = [number, number];
|
|
||||||
|
|
||||||
interface TextProperties {
|
interface TextProperties {
|
||||||
row: number;
|
row: number;
|
||||||
column: number;
|
column: number;
|
||||||
@@ -136,14 +134,9 @@ export default class WorksheetCanvas {
|
|||||||
this.onRowHeightChanges = options.onRowHeightChanges;
|
this.onRowHeightChanges = options.onRowHeightChanges;
|
||||||
this.resetHeaders();
|
this.resetHeaders();
|
||||||
this.cellOutlineHandle = attachOutlineHandle(this);
|
this.cellOutlineHandle = attachOutlineHandle(this);
|
||||||
// +1 means the cell is filled with a spill from a cell in the left
|
|
||||||
// -1 means the cell is filled with a spill from a cell in the right
|
|
||||||
this.spills = new Map<string, number>();
|
|
||||||
this.cells = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
removeSpills(): void {
|
// a cell marked as "spill" means its left border should be skipped
|
||||||
this.spills.clear();
|
this.spills = new Map<string, number>();
|
||||||
this.cells = [];
|
this.cells = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,12 +678,14 @@ export default class WorksheetCanvas {
|
|||||||
leftColumnX > minX &&
|
leftColumnX > minX &&
|
||||||
this.model.getFormattedCellValue(selectedSheet, row, spillColumn) ===
|
this.model.getFormattedCellValue(selectedSheet, row, spillColumn) ===
|
||||||
"" &&
|
"" &&
|
||||||
spillColumn > 0 &&
|
spillColumn >= 1 &&
|
||||||
((column <= frozenColumnsCount && spillColumn <= frozenColumnsCount) ||
|
((column <= frozenColumnsCount && spillColumn <= frozenColumnsCount) ||
|
||||||
column > frozenColumnsCount)
|
column > frozenColumnsCount)
|
||||||
) {
|
) {
|
||||||
leftColumnX -= this.getColumnWidth(selectedSheet, spillColumn);
|
leftColumnX -= this.getColumnWidth(selectedSheet, spillColumn);
|
||||||
// marks (row, spillColumn) as spilling so we don't draw a border to the left
|
// This is tricky but correct. The reason is we only draw the left borders of the cells
|
||||||
|
// (because the left border of a cell MUST be the right border of the one to the left).
|
||||||
|
// So if we want to remove the right border of this cell we need to skip the left border of the next.
|
||||||
this.spills.set(`${row}-${spillColumn + 1}`, 1);
|
this.spills.set(`${row}-${spillColumn + 1}`, 1);
|
||||||
spillColumn -= 1;
|
spillColumn -= 1;
|
||||||
}
|
}
|
||||||
@@ -1735,12 +1730,6 @@ export default class WorksheetCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderSheet(): void {
|
renderSheet(): void {
|
||||||
console.time("renderSheet");
|
|
||||||
this._renderSheet();
|
|
||||||
console.timeEnd("renderSheet");
|
|
||||||
}
|
|
||||||
|
|
||||||
_renderSheet(): void {
|
|
||||||
const context = this.ctx;
|
const context = this.ctx;
|
||||||
const { canvas } = this;
|
const { canvas } = this;
|
||||||
const selectedSheet = this.model.getSelectedSheet();
|
const selectedSheet = this.model.getSelectedSheet();
|
||||||
|
|||||||
Reference in New Issue
Block a user