@@ -17,8 +17,9 @@ import (
17
17
)
18
18
19
19
var (
20
- lastID int
21
- idMtx sync.Mutex
20
+ lastID int
21
+ idMtx sync.Mutex
22
+
22
23
listWidth , listHeight , _ = term .GetSize (0 )
23
24
)
24
25
@@ -135,9 +136,19 @@ func DefaultStylesWithRenderer(r *lipgloss.Renderer) Styles {
135
136
Selected : r .NewStyle ().Foreground (lipgloss .Color ("212" )).Bold (true ),
136
137
FileSize : r .NewStyle ().Foreground (lipgloss .Color ("240" )).Width (fileSizeWidth ).Align (lipgloss .Right ),
137
138
EmptyDirectory : r .NewStyle ().Foreground (lipgloss .Color ("240" )).PaddingLeft (paddingLeft ).SetString ("Bummer. No Files Found." ),
138
- SinglePaneStyle : r .NewStyle ().MarginRight (2 ).Height (listHeight - 2 ).Width (listWidth - 2 ),
139
- LeftPaneStyle : r .NewStyle ().MarginRight (2 ).Height (listHeight - 2 ).Width (listWidth / 2 - 2 ).Border (lipgloss .NormalBorder (), false , true , false , false ),
140
- RightPaneStyle : r .NewStyle ().MarginRight (2 ).Height (listHeight - 2 ).Width (listWidth / 2 - 2 ),
139
+ SinglePaneStyle : r .NewStyle ().
140
+ MarginRight (2 ).
141
+ Height (listHeight - 2 ).
142
+ Width (listWidth - 2 ),
143
+ LeftPaneStyle : r .NewStyle ().
144
+ Border (lipgloss .NormalBorder (), false , true , false , false ).
145
+ MarginRight (2 ).
146
+ Height (listHeight - 2 ).
147
+ Width (listWidth / 2 - 2 ),
148
+ RightPaneStyle : r .NewStyle ().
149
+ MarginRight (2 ).
150
+ Height (listHeight - 2 ).
151
+ Width (listWidth / 2 - 2 ),
141
152
}
142
153
}
143
154
@@ -219,8 +230,25 @@ func (m Model) readDir(path string, showHidden bool) tea.Cmd {
219
230
return errorMsg {err }
220
231
}
221
232
222
- sanitizedDirEntries := getCleanDirEntries (dirEntries , showHidden )
233
+ sort .Slice (dirEntries , func (i , j int ) bool {
234
+ if dirEntries [i ].IsDir () == dirEntries [j ].IsDir () {
235
+ return dirEntries [i ].Name () < dirEntries [j ].Name ()
236
+ }
237
+ return dirEntries [i ].IsDir ()
238
+ })
223
239
240
+ if showHidden {
241
+ return readDirMsg {id : m .id , entries : dirEntries }
242
+ }
243
+
244
+ var sanitizedDirEntries []os.DirEntry
245
+ for _ , dirEntry := range dirEntries {
246
+ isHidden , _ := IsHidden (dirEntry .Name ())
247
+ if isHidden {
248
+ continue
249
+ }
250
+ sanitizedDirEntries = append (sanitizedDirEntries , dirEntry )
251
+ }
224
252
return readDirMsg {id : m .id , entries : sanitizedDirEntries }
225
253
}
226
254
}
@@ -386,16 +414,24 @@ func (m Model) View() string {
386
414
var s strings.Builder
387
415
if m .selectedStack .Length () > 0 {
388
416
if m .DualPane {
389
- rPane := m .Styles .EmptyDirectory .String ()
390
- if len (m .files ) > 0 {
391
- rPane = paneWriter (m )
417
+ if len (m .files ) == 0 {
418
+ s .WriteString (lipgloss .JoinHorizontal (lipgloss .Top ,
419
+ m .Styles .LeftPaneStyle .Render (
420
+ lPaneWriter (m .CurrentDirectory , m .Height ),
421
+ ),
422
+ m .Styles .RightPaneStyle .Render (
423
+ m .Styles .EmptyDirectory .String (),
424
+ ),
425
+ ))
426
+ return s .String ()
392
427
}
393
-
394
428
s .WriteString (lipgloss .JoinHorizontal (lipgloss .Top ,
395
429
m .Styles .LeftPaneStyle .Render (
396
430
lPaneWriter (m .CurrentDirectory , m .Height ),
397
431
),
398
- m .Styles .RightPaneStyle .Render (rPane ),
432
+ m .Styles .RightPaneStyle .Render (
433
+ paneWriter (m ),
434
+ ),
399
435
))
400
436
return s .String ()
401
437
}
0 commit comments