@@ -2,8 +2,6 @@ package ui
2
2
3
3
import (
4
4
"fmt"
5
- "path/filepath"
6
- "slices"
7
5
"strings"
8
6
9
7
"github.com/bluekeyes/go-gitdiff/gitdiff"
@@ -257,6 +255,10 @@ func (m mainModel) View() string {
257
255
)
258
256
}
259
257
258
+ type fileTreeMsg struct {
259
+ files []* gitdiff.File
260
+ }
261
+
260
262
func (m mainModel ) fetchFileTree () tea.Msg {
261
263
// TODO: handle error
262
264
files , _ , err := gitdiff .Parse (strings .NewReader (m .input + "\n " ))
@@ -268,41 +270,6 @@ func (m mainModel) fetchFileTree() tea.Msg {
268
270
return fileTreeMsg {files : files }
269
271
}
270
272
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
-
306
273
func (m mainModel ) footerView () string {
307
274
return lipgloss .NewStyle ().
308
275
Width (m .width ).
@@ -336,11 +303,6 @@ func (m mainModel) sidebarWidth() int {
336
303
}
337
304
}
338
305
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
-
344
306
func (m * mainModel ) stopSearch () {
345
307
m .searching = false
346
308
m .search .SetValue ("" )
0 commit comments