aboutsummaryrefslogtreecommitdiffstats
path: root/src/i_insert.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/i_insert.go')
-rw-r--r--src/i_insert.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/i_insert.go b/src/i_insert.go
index d9a3e40..f87510d 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -110,17 +110,29 @@ func i_insert_host(data *HardData, insert *HostNode) {
// data.litems.curr.Host.next = insert
// data.litems.curr.Host.next.next = tmp_next
// }
+ var next *ItemsNode = nil
+ if data.litems.curr != nil {
+ next = data.litems.curr.next
+ }
item := &ItemsNode{
0,
nil,
insert,
data.litems.curr,
- data.litems.curr.next,
+ next,
+ }
+ curr := data.litems.curr
+ if curr != nil {
+ curr.next = item
+ if curr.next.next != nil {
+ data.litems.curr.next.next.prev = item
+ }
+ data.litems.curr = data.litems.curr.next
+ } else {
+ data.litems.add_back(item)
+ data.litems.curr = data.litems.head
}
- data.litems.curr.next = item
- data.litems.curr.next.next.prev = item
data.litems.reset_id()
- data.litems.curr = data.litems.curr.next
data.ui.mode = NORMAL_MODE
data.insert = nil
}