Skip to content

Commit acc3539

Browse files
authored
Only ignore comments when finding insertion point (#197)
1 parent 92fe5ec commit acc3539

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.4.4
2+
3+
### Division Migrator
4+
5+
* Fix a bug where `@use "sass:math"` would sometimes be incorrectly inserted
6+
after other rules.
7+
18
## 1.4.3
29

310
### Division Migrator

lib/src/migrators/division.dart

+3-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,9 @@ class _DivisionMigrationVisitor extends MigrationVisitor {
9191
var useRules = _useRulesToInsert.join('\n');
9292
var insertionPoint = node.span.start;
9393
for (var child in node.children) {
94-
if (child is UseRule || child is ForwardRule || child is ImportRule) {
95-
insertionPoint = child.span.start;
96-
break;
97-
}
94+
if (child is LoudComment || child is SilentComment) continue;
95+
insertionPoint = child.span.start;
96+
break;
9897
}
9998
addPatch(Patch.insert(insertionPoint, '$useRules\n\n'));
10099
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass_migrator
2-
version: 1.4.3
2+
version: 1.4.4
33
description: A tool for running migrations on Sass files
44
author: Jennifer Thakar <[email protected]>
55
homepage: https://github.com/sass/migrator
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<==> input/entrypoint.scss
2+
// Comment
3+
4+
a {
5+
b: 3 / $x;
6+
c: (six / three);
7+
}
8+
9+
@import "other";
10+
11+
<==> output/entrypoint.scss
12+
// Comment
13+
14+
@use "sass:math";
15+
@use "sass:list";
16+
17+
a {
18+
b: math.div(3, $x);
19+
c: list.slash(six, three);
20+
}
21+
22+
@import "other";

0 commit comments

Comments
 (0)