File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,13 @@ import (
6
6
"os"
7
7
"os/user"
8
8
"path/filepath"
9
+ "regexp"
9
10
"syscall"
10
11
"time"
11
12
)
12
13
14
+ var whitespaceRegex = regexp .MustCompile (`\r|\r?\n` )
15
+
13
16
// Node - Contains all info necessary to render file or directory
14
17
type Node struct {
15
18
Icon rune
@@ -64,14 +67,16 @@ func New(file os.FileInfo) Node {
64
67
}
65
68
66
69
func name (file os.FileInfo ) string {
70
+ baseName := file .Name ()
71
+ baseName = whitespaceRegex .ReplaceAllString (baseName , "?" )
67
72
if ! file .IsDir () {
68
- return file . Name ()
73
+ return baseName
69
74
}
70
- name := fmt .Sprintf ("%s/" , file . Name () )
75
+ name := fmt .Sprintf ("%s/" , baseName )
71
76
// inject name for current and parent directories
72
77
// TODO: properly inject names for non-current directories
73
- if file . Name () == "." || file . Name () == ".." {
74
- fullpath , _ := filepath .Abs (file . Name () )
78
+ if baseName == "." || baseName == ".." {
79
+ fullpath , _ := filepath .Abs (baseName )
75
80
name = fmt .Sprintf ("%s [%s]" , name , filepath .Base (fullpath ))
76
81
}
77
82
return name
You can’t perform that action at this time.
0 commit comments