Skip to content

Commit 6f3d490

Browse files
committed
feat: negative substr length from end
`svar_substr thing 0 -x` removes the last x characters of thing
1 parent 663651b commit 6f3d490

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Features/ConfigPlus.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ CON_COMMAND_F_COMPLETION(svar_substr, "svar_substr <variable> <from> [len] - set
164164
if (from < 0 || (unsigned)from > value.length()) {
165165
return console->Print("Substring index out of bounds of variable\n");
166166
}
167+
168+
if (len < 0) len += value.length();
169+
167170
if (len < 0) {
168171
return console->Print("Negative length of substring\n");
169172
}

0 commit comments

Comments
 (0)