mirror of
https://github.com/zyedidia/micro
synced 2024-09-30 21:23:41 +00:00
Fix diff remove problem in ApplyDiff
The location counter was being updated when there was a removal in the text but it shouldn't be. Fixes #163
This commit is contained in:
parent
cdfea45a49
commit
553b3d80c4
|
@ -66,12 +66,14 @@ func (eh *EventHandler) ApplyDiff(new string) {
|
|||
diff := differ.DiffMain(eh.buf.String(), new, false)
|
||||
loc := eh.buf.Start()
|
||||
for _, d := range diff {
|
||||
if d.Type == dmp.DiffInsert {
|
||||
eh.Insert(loc, d.Text)
|
||||
} else if d.Type == dmp.DiffDelete {
|
||||
if d.Type == dmp.DiffDelete {
|
||||
eh.Remove(loc, loc.Move(Count(d.Text), eh.buf))
|
||||
} else {
|
||||
if d.Type == dmp.DiffInsert {
|
||||
eh.Insert(loc, d.Text)
|
||||
}
|
||||
loc = loc.Move(Count(d.Text), eh.buf)
|
||||
}
|
||||
loc = loc.Move(Count(d.Text), eh.buf)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue