()
| 101 | } |
| 102 | |
| 103 | func (self *FileTreeViewModel) SetTree() { |
| 104 | newFiles := self.GetAllFiles() |
| 105 | selectedNode := self.GetSelected() |
| 106 | |
| 107 | // for when you stage the old file of a rename and the new file is in a collapsed dir |
| 108 | for _, file := range newFiles { |
| 109 | if selectedNode != nil && selectedNode.path != "" && file.PreviousPath == selectedNode.path { |
| 110 | self.ExpandToPath(file.Path) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | prevNodes := self.GetAllItems() |
| 115 | prevSelectedLineIdx := self.GetSelectedLineIdx() |
| 116 | |
| 117 | self.IFileTree.SetTree() |
| 118 | |
| 119 | if selectedNode != nil { |
| 120 | newNodes := self.GetAllItems() |
| 121 | newIdx := self.findNewSelectedIdx(prevNodes[prevSelectedLineIdx:], newNodes) |
| 122 | if newIdx != -1 && newIdx != prevSelectedLineIdx { |
| 123 | self.SetSelection(newIdx) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | self.ClampSelection() |
| 128 | } |
| 129 | |
| 130 | // Let's try to find our file again and move the cursor to that. |
| 131 | // If we can't find our file, it was probably just removed by the user. In that |
nothing calls this directly
no test coverage detected