-
Notifications
You must be signed in to change notification settings - Fork 72
fix!: use the same cell reference constructor in order to ensure consistency #4634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
245d39b
2af83b6
fe708df
6227ec5
268ff65
066e1d2
7105375
893994a
31fa8ac
8f08024
9158159
5476fdd
09928c6
530e9e7
27ce9d9
f58821b
60dd913
e20b0fe
e380adc
8760538
b02d467
ce3b070
ef5e461
e874832
2327868
98e7b94
b236546
ae9f2d2
ae25f93
30c0bcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -334,7 +334,9 @@ private void fireCellValueChangeEvent(CellRangeAddress region) { | |||||||||
| for (int x = region.getFirstColumn(); x <= region | ||||||||||
| .getLastColumn(); x++) { | ||||||||||
| for (int y = region.getFirstRow(); y <= region.getLastRow(); y++) { | ||||||||||
| cells.add(new CellReference(y, x)); | ||||||||||
| cells.add(new CellReference( | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main issue with the overall change to include spreadsheet names into the cell references is that if a developer is already using cell references without the sheet name, the comparison will now fail. And that's quite easy to achieve, as We could consider adding both types of references (with and without sheet name) to the events. For example, for cell value change events we could modify the logic here: Lines 796 to 799 in 245d39b
To something like: private void fireCellValueChangeEvent(Set<CellReference> changedCells) {
List<CellReference> cellRefsWithSheetName = changedCells
.stream()
.filter(ref -> ref.getSheetName() != null)
.toList();
cellRefsWithSheetName.forEach(ref -> {
CellReference refWithoutSheetName = new CellReference(ref.getRow(), ref.getCol());
changedCells.add(refWithoutSheetName);
});
spreadsheet
.fireEvent(new CellValueChangeEvent(spreadsheet, changedCells));
}The downside would be that a change to a single cell will report two changes in the event. Though that might be the lesser evil than relying on which There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in the latest version |
||||||||||
| spreadsheet.getActiveSheet().getSheetName(), y, x, | ||||||||||
| false, false)); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| fireCellValueChangeEvent(cells); | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,7 +148,8 @@ public void captureCellRangeValues(CellRangeAddress... cellRanges) { | |
|
|
||
| @Override | ||
| public CellReference getSelectedCellReference() { | ||
| return new CellReference(selectedCellRow, selectedcellCol); | ||
| return new CellReference(spreadsheet.getActiveSheet().getSheetName(), | ||
|
||
| selectedCellRow, selectedcellCol, false, false); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -339,13 +340,15 @@ public Set<CellReference> getChangedCells() { | |
| for (Object o : values) { | ||
| if (o instanceof CellValue) { | ||
| CellValue cellValue = (CellValue) o; | ||
| changedCells | ||
| .add(new CellReference(cellValue.row, cellValue.col)); | ||
| changedCells.add(new CellReference( | ||
| spreadsheet.getActiveSheet().getSheetName(), | ||
| cellValue.row, cellValue.col, false, false)); | ||
| } else { | ||
| CellRangeValue cellRangeValue = (CellRangeValue) o; | ||
| for (int r = cellRangeValue.row1; r <= cellRangeValue.row2; r++) { | ||
| for (int c = cellRangeValue.col1; c <= cellRangeValue.col2; c++) { | ||
| changedCells.add(new CellReference(r, c)); | ||
| changedCells.add(new CellReference( | ||
| getSheet().getSheetName(), r, c, false, false)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NULL_DEREFERENCE: object
selectedCellReferencelast assigned on line 398 could be null and is dereferenced by call toisCellInRange(...)at line 401.ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
@sonatype-lift ignore@sonatype-lift ignoreall@sonatype-lift exclude <file|issue|path|tool>file|issue|path|toolfrom Lift findings by updating your config.toml fileNote: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]