From f6c20068b0ddcf1cbd850ea7fb9040ce19eff6a2 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 29 Oct 2025 00:54:54 +0100 Subject: [PATCH] Fix the operator span when parsing a standalone `%` --- CHANGELOG.md | 4 ++++ lib/src/parse/stylesheet.dart | 3 ++- pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68f510e21..198774076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.93.3-dev + +* Fix the span reported for standalone `%` expressions followed by whitespace. + ## 1.93.2 * No user-visible changes. diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index 9849bbbfa..e5572e3d9 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -2128,11 +2128,12 @@ abstract class StylesheetParser extends Parser { length: operator.operator.length, ); } + var operatorEnd = scanner.position; whitespace(consumeNewlines: true); if (operator == BinaryOperator.modulo && !_lookingAtExpression()) { addSingleExpression(StringExpression.plain( - '%', scanner.spanFromPosition(scanner.position - 1))); + '%', scanner.spanFromPosition(operatorEnd - 1, operatorEnd))); } else { operators.add(operator); operands.add(singleExpression); diff --git a/pubspec.yaml b/pubspec.yaml index 8ea5cf123..cfbd482dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.93.2 +version: 1.93.3-dev description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass