func (s *FilesTreeStore) Remove(c tr.Cursor) (prefix string, index int) { s.deleteSubtree(c.Path) var suffix string if strings.Contains(c.Path, ":") { prefix = c.Path[:strings.LastIndex(c.Path, ":")] suffix = c.Path[strings.LastIndex(c.Path, ":")+1:] } else { suffix = c.Path } fmt.Sscanf(suffix, "%d", &index) i := index for ok := true; ok; i++ { ok = s.shiftLookup(prefix, fmt.Sprintf("%d", i+1), fmt.Sprintf("%d", i)) } _, ok := s.lookup[c.Path] if !ok { log.Printf("FilesTreeStore.Remove: c.Path=%s not found, decreasing\n", c.Path) index-- suffix = fmt.Sprintf("%d", index) if len(prefix) > 0 { c.Path = fmt.Sprintf("%s:%d", prefix, index) } else { c.Path = fmt.Sprintf("%d", index) } log.Printf("FilesTreeStore.Remove: new c.Path=%s\n", c.Path) _, ok = s.lookup[c.Path] if !ok { s.currentSelection = nil } else { _, s.currentSelection, _ = s.getObjAndIterById(c.Path) } } return }