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 string.insert with negative indices #1598

Merged
merged 1 commit into from Jan 14, 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
6 changes: 5 additions & 1 deletion CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.48.1

* Fix a bug in `string.insert` with certain negative indices.

## 1.48.0

### JS API
Expand All @@ -23,7 +27,7 @@

* **Potentially breaking bug fix:** Match the specification of the new JS API by
passing `undefined` rather than `null` to `Logger.warn()` for an unset `span`.

#### TypeScript Declarations

* Add a declaration for the `LegacyPluginThis.options.context` field.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/functions/string.dart
Expand Up @@ -66,7 +66,7 @@ final _insert = _function("insert", r"$string, $insert, $index", (arguments) {
if (indexInt < 0) {
// +1 because negative indexes start counting from -1 rather than 0, and
// another +1 because we want to insert *after* that index.
indexInt = string.sassLength + indexInt + 2;
indexInt = math.max(string.sassLength + indexInt + 2, 0);
}

var codepointIndex = _codepointForIndex(indexInt, string.sassLength);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: sass
version: 1.48.0
version: 1.48.1-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down