From 5ae20512aff74eb8393a2b39938ea5db988ff125 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 25 Feb 2018 12:53:42 +0100 Subject: [PATCH] Fix inserting before/after a range into the string --- source/tanya/container/string.d | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/tanya/container/string.d b/source/tanya/container/string.d index 40dabb6..b48522b 100644 --- a/source/tanya/container/string.d +++ b/source/tanya/container/string.d @@ -1564,10 +1564,12 @@ struct String } do { - auto oldLen = this.data + length; + const oldLength = length; + const rangeEnd = r.end - this.data; const inserted = insertBack(el); - bringToFront(ByCodeUnit!char(this, r.end, oldLen), - ByCodeUnit!char(this, oldLen, this.data + length)); + auto containerEnd = this.data + oldLength; + bringToFront(ByCodeUnit!char(this, this.data + rangeEnd, containerEnd), + ByCodeUnit!char(this, containerEnd, this.data + length)); return inserted; }