Skip to content

Commit

Permalink
[FIX] range: Support ranges with no Rangeparts
Browse files Browse the repository at this point in the history
The current typing of `RangeImpl.parts` is such that we have to support
the presence of 0, 1 or 2 parts defined in the `Range` object. We only
supported the last 2 cases.

closes #3459

Task: 3608941
X-original-commit: afc1b33
Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
  • Loading branch information
rrahir committed Jan 17, 2024
1 parent 2c1b136 commit 54cf3c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plugins/core/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ export class RangeAdapter implements CommandHandler<CoreCommand> {
* Get a Xc string that represent a part of a range
*/
private getRangePartString(range: RangeImpl, part: 0 | 1): string {
const colFixed = range.parts && range.parts[part].colFixed ? "$" : "";
const colFixed = range.parts && range.parts[part]?.colFixed ? "$" : "";
const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
const rowFixed = range.parts && range.parts[part].rowFixed ? "$" : "";
const rowFixed = range.parts && range.parts[part]?.rowFixed ? "$" : "";
const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);

let str = "";
Expand Down
6 changes: 6 additions & 0 deletions tests/plugins/range.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ describe("range plugin", () => {
expect(m.getters.getRangeString(undefined, "not there")).toBe(INCORRECT_RANGE_STRING);
});

test("requesting a range without parts", () => {
const r = m.getters.getRangeFromSheetXC("s1", "A1");
const rNoParts = r.clone({ parts: [] });
expect(m.getters.getRangeString(rNoParts, "forceSheetName")).toBe("s1!A1");
});

test.each(["Sheet 0", "<Sheet1>", "&Sheet2", "Sheet4;", "Sheet5🐻"])(
"sheet name with special character %s",
(name) => {
Expand Down

0 comments on commit 54cf3c0

Please sign in to comment.