@@ -2,8 +2,6 @@ package ui
22
33import (
44 "fmt"
5- "path/filepath"
6- "slices"
75 "strings"
86
97 "github.com/bluekeyes/go-gitdiff/gitdiff"
@@ -257,6 +255,10 @@ func (m mainModel) View() string {
257255 )
258256}
259257
258+ type fileTreeMsg struct {
259+ files []* gitdiff.File
260+ }
261+
260262func (m mainModel ) fetchFileTree () tea.Msg {
261263 // TODO: handle error
262264 files , _ , err := gitdiff .Parse (strings .NewReader (m .input + "\n " ))
@@ -268,41 +270,6 @@ func (m mainModel) fetchFileTree() tea.Msg {
268270 return fileTreeMsg {files : files }
269271}
270272
271- type fileTreeMsg struct {
272- files []* gitdiff.File
273- }
274-
275- func sortFiles (files []* gitdiff.File ) {
276- slices .SortFunc (files , func (a * gitdiff.File , b * gitdiff.File ) int {
277- nameA := filenode .GetFileName (a )
278- nameB := filenode .GetFileName (b )
279- dira := filepath .Dir (nameA )
280- dirb := filepath .Dir (nameB )
281- if dira != "." && dirb != "." && dira == dirb {
282- return strings .Compare (strings .ToLower (nameA ), strings .ToLower (nameB ))
283- }
284-
285- if dira != "." && dirb == "." {
286- return - 1
287- }
288- if dirb != "." && dira == "." {
289- return 1
290- }
291-
292- if dira != "." && dirb != "." {
293- if strings .HasPrefix (dira , dirb ) {
294- return - 1
295- }
296-
297- if strings .HasPrefix (dirb , dira ) {
298- return 1
299- }
300- }
301-
302- return strings .Compare (strings .ToLower (nameA ), strings .ToLower (nameB ))
303- })
304- }
305-
306273func (m mainModel ) footerView () string {
307274 return lipgloss .NewStyle ().
308275 Width (m .width ).
@@ -336,11 +303,6 @@ func (m mainModel) sidebarWidth() int {
336303 }
337304}
338305
339- func (m mainModel ) setDiffViewerDimensions () tea.Cmd {
340- dfCmd := m .diffViewer .SetSize (m .width - m .sidebarWidth (), m .height - footerHeight - headerHeight )
341- return dfCmd
342- }
343-
344306func (m * mainModel ) stopSearch () {
345307 m .searching = false
346308 m .search .SetValue ("" )
0 commit comments