From d7b61ecfa8d879f1abdc3f5ec958ee04aea540bf Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Tue, 17 May 2016 19:57:16 -0400 Subject: [PATCH] Fix small bug in Remove function in buffer --- cmd/micro/buffer.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/micro/buffer.go b/cmd/micro/buffer.go index 238e1887..da5e6757 100644 --- a/cmd/micro/buffer.go +++ b/cmd/micro/buffer.go @@ -101,6 +101,9 @@ func (b *Buffer) Remove(start, end int) string { if end > b.Len() { end = b.Len() } + if start == end { + return "" + } removed := b.Substr(start, end) // The rope implenentation I am using wants indicies starting at 1 instead of 0 start++ @@ -110,6 +113,7 @@ func (b *Buffer) Remove(start, end int) string { return removed } +// Substr returns the substring of the rope from start to end func (b *Buffer) Substr(start, end int) string { return b.r.Substr(start+1, end-start).String() }