Skip to content

Commit ae6275e

Browse files
authored
fix serializing loud comment crash when importing the same file twice in a row (#1713)
* fix serializing loud comment crash when importing the same file twice
1 parent 44c2966 commit ae6275e

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.52.3
2+
3+
* Fix crash when trailing loud comments (`/* ... */`) appear twice in a row
4+
across two different imports which themselves imported the same file each.
5+
16
## 1.52.2
27

38
* Preserve location of trailing loud comments (`/* ... */`) instead of pushing

lib/src/visitor/serialize.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,11 @@ class _SerializeVisitor
13561356
// simple forward search of the previous.span.text as that might contain
13571357
// other left braces.
13581358
var searchFrom = node.span.start.offset - previous.span.start.offset - 1;
1359+
1360+
// Imports can cause a node to be "contained" by another node when they are
1361+
// actually the same node twice in a row.
1362+
if (searchFrom < 0) return false;
1363+
13591364
var endOffset = previous.span.text.lastIndexOf("{", searchFrom);
13601365
endOffset = math.max(0, endOffset);
13611366
var span = previous.span.file.span(

pkg/sass_api/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.0-beta.48
2+
3+
* No user-visible changes.
4+
15
## 1.0.0-beta.47
26

37
* No user-visible changes.

pkg/sass_api/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 1.0.0-beta.47
5+
version: 1.0.0-beta.48
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
10-
sdk: '>=2.12.0 <3.0.0'
10+
sdk: ">=2.12.0 <3.0.0"
1111

1212
dependencies:
13-
sass: 1.52.2
13+
sass: 1.52.3
1414

1515
dev_dependencies:
1616
dartdoc: ^5.0.0
1717

1818
dependency_overrides:
19-
sass: {path: ../..}
19+
sass: { path: ../.. }

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.52.2
2+
version: 1.52.3
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

@@ -8,7 +8,7 @@ executables:
88
sass: sass
99

1010
environment:
11-
sdk: '>=2.12.0 <3.0.0'
11+
sdk: ">=2.12.0 <3.0.0"
1212

1313
dependencies:
1414
args: ^2.0.0

0 commit comments

Comments
 (0)