From 93552e2e314955bc6acc62b28296745a79857bfd Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Mon, 23 Nov 2020 18:27:09 +0800 Subject: [PATCH] fix rope index (#16100) * fix rope index * add testcase (cherry picked from commit ab2c082cb3e9e411571fa0936776762bc0c8fd94) --- lib/pure/ropes.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/ropes.nim b/lib/pure/ropes.nim index c2055cafca..e4e05ba47f 100644 --- a/lib/pure/ropes.nim +++ b/lib/pure/ropes.nim @@ -204,8 +204,8 @@ proc `[]`*(r: Rope, i: int): char {.rtl, extern: "nroCharAt".} = if x.left.length > j: x = x.left else: + dec(j, x.left.length) x = x.right - dec(j, x.len) iterator leaves*(r: Rope): string = ## iterates over any leaf string in the rope `r`.