Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit b9b5756

Browse files
authored
Merge pull request #2254 from xzyfer/fix/str-slice-more
Fix an addition bug with str-slice
2 parents f43d007 + e87574b commit b9b5756

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/functions.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,14 +1016,21 @@ namespace Sass {
10161016
String_Constant* s = ARG("$string", String_Constant);
10171017
double start_at = ARG("$start-at", Number)->value();
10181018
double end_at = ARG("$end-at", Number)->value();
1019+
String_Quoted* ss = dynamic_cast<String_Quoted*>(s);
10191020

10201021
std::string str = unquote(s->value());
10211022

10221023
size_t size = utf8::distance(str.begin(), str.end());
10231024

1024-
if (end_at < size * -1.0 && size > 1) {
1025-
end_at = 0;
1025+
if (!dynamic_cast<Number*>(env["$end-at"])) {
1026+
end_at = -1;
10261027
}
1028+
1029+
if (end_at == 0 || (end_at + size) < 0) {
1030+
if (ss && ss->quote_mark()) newstr = quote("");
1031+
return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, newstr);
1032+
}
1033+
10271034
if (end_at < 0) {
10281035
end_at += size + 1;
10291036
if (end_at == 0) end_at = 1;

0 commit comments

Comments
 (0)