From 76e60ad7fe6738fa1918fc525feb24bd5b2e8b38 Mon Sep 17 00:00:00 2001 From: Eugene Pobochny Date: Fri, 22 Aug 2025 16:00:07 -0400 Subject: [PATCH] refactor: TextBuf --- src/text-buf.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/text-buf.ts b/src/text-buf.ts index 3d0955e..7d9fa2a 100644 --- a/src/text-buf.ts +++ b/src/text-buf.ts @@ -406,17 +406,17 @@ export class TextBuf { while (!x.nil) { if (index < x.left.total_len) { x = x.left; - } else { - index -= x.left.total_len; + continue; + } - if (index < x.slice_len) { - return { node: x, offset: index }; - } else { - index -= x.slice_len; + index -= x.left.total_len; - x = x.right; - } + if (index < x.slice_len) { + return { node: x, offset: index }; } + + index -= x.slice_len; + x = x.right; } }