mirror of
https://github.com/Hopiu/micro.git
synced 2026-05-21 04:41:53 +00:00
Fix small bug in Remove function in buffer
This commit is contained in:
parent
94d2bc3cb0
commit
d7b61ecfa8
1 changed files with 4 additions and 0 deletions
|
|
@ -101,6 +101,9 @@ func (b *Buffer) Remove(start, end int) string {
|
||||||
if end > b.Len() {
|
if end > b.Len() {
|
||||||
end = b.Len()
|
end = b.Len()
|
||||||
}
|
}
|
||||||
|
if start == end {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
removed := b.Substr(start, end)
|
removed := b.Substr(start, end)
|
||||||
// The rope implenentation I am using wants indicies starting at 1 instead of 0
|
// The rope implenentation I am using wants indicies starting at 1 instead of 0
|
||||||
start++
|
start++
|
||||||
|
|
@ -110,6 +113,7 @@ func (b *Buffer) Remove(start, end int) string {
|
||||||
return removed
|
return removed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Substr returns the substring of the rope from start to end
|
||||||
func (b *Buffer) Substr(start, end int) string {
|
func (b *Buffer) Substr(start, end int) string {
|
||||||
return b.r.Substr(start+1, end-start).String()
|
return b.r.Substr(start+1, end-start).String()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue