Review fix for #2473: a repeated sheet name matches in any case

Sheet1!A1:SHEET1!B2 is a range whose second end repeats the sheet, as
Sheet1!A1:Sheet1!B2 is: the check uses same_name, Excel's case-insensitive
name comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-25 09:56:18 -04:00
co-authored by Claude Opus 5.5
parent 0665476b35
commit 4eb2fb5c8e
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -346,7 +346,7 @@ pub fn tokenize_locale(src: &str, locale: crate::FormulaLocale) -> Result<Vec<To
// `Sheet1!A1:Sheet1!B2` is a range whose second end repeats the sheet, not a span.
let repeats_sheet = is_range_end(&w)
&& matches!(out.last(), Some(Token { tok: Tok::Sheet(p, None), .. })
if chars.get(j + 1..k).is_some_and(|s| s.iter().map(|c| c.1).eq(p.chars())));
if chars.get(j + 1..k).is_some_and(|s| crate::same_name(&s.iter().map(|c| c.1).collect::<String>(), p)));
k > j + 1 && ch(k) == Some('!') && !repeats_sheet
} {
let mut k = j + 1;
+2
View File
@@ -10,6 +10,8 @@ fn range_end_repeating_sheet_name_round_trips() {
assert_eq!(rt("'a'!A1:'a'!B2"), "a!A1:a!B2");
assert_eq!(rt("Sheet1!A1:Sheet1!B2"), "Sheet1!A1:Sheet1!B2");
assert_eq!(rt("SUM(a!A1:a!B2)"), "SUM(a!A1:a!B2)");
// Sheet names match without regard to case, as Excel's do.
assert_eq!(rt("Sheet1!A1:SHEET1!B2"), "Sheet1!A1:SHEET1!B2");
}
#[test]