Skip to content
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

fix serializing loud comment crash when importing the same file twice in a row #1713

Merged
merged 2 commits into from Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
## 1.52.3

* Fix crash when trailing loud comments (`/* ... */`) appear twice in a row
across two different imports which themselves imported the same file each.

## 1.52.2

* Preserve location of trailing loud comments (`/* ... */`) instead of pushing
Expand Down
5 changes: 5 additions & 0 deletions lib/src/visitor/serialize.dart
Expand Up @@ -1356,6 +1356,11 @@ class _SerializeVisitor
// simple forward search of the previous.span.text as that might contain
// other left braces.
var searchFrom = node.span.start.offset - previous.span.start.offset - 1;

// Imports can cause a node to be "contained" by another node when they are
// actually the same node twice in a row.
if (searchFrom < 0) return false;

var endOffset = previous.span.text.lastIndexOf("{", searchFrom);
endOffset = math.max(0, endOffset);
var span = previous.span.file.span(
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.0.0-beta.48

* No user-visible changes.

## 1.0.0-beta.47

* No user-visible changes.
Expand Down
8 changes: 4 additions & 4 deletions pkg/sass_api/pubspec.yaml
Expand Up @@ -2,18 +2,18 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 1.0.0-beta.47
version: 1.0.0-beta.48
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ">=2.12.0 <3.0.0"

dependencies:
sass: 1.52.2
sass: 1.52.3

dev_dependencies:
dartdoc: ^5.0.0

dependency_overrides:
sass: {path: ../..}
sass: { path: ../.. }
4 changes: 2 additions & 2 deletions pubspec.yaml
@@ -1,5 +1,5 @@
name: sass
version: 1.52.2
version: 1.52.3
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand All @@ -8,7 +8,7 @@ executables:
sass: sass

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ">=2.12.0 <3.0.0"

dependencies:
args: ^2.0.0
Expand Down