commit 664fe0e
delthas
·
2025-08-23 12:37:01 +0000 UTC
parent 0341fb8
Fix autocompletion for relative UPLOAD paths
1 files changed,
+16,
-8
+16,
-8
1@@ -190,23 +190,31 @@ func (app *App) completionsUpload(cs []ui.Completion, cursorIdx int, text []rune
2 return cs
3 }
4
5+ var home string
6+ if h, err := os.UserHomeDir(); err == nil {
7+ home = h
8+ }
9 dirPath := ""
10 dirPrefix := ""
11 if path == "" {
12- home, err := os.UserHomeDir()
13- if err != nil {
14+ if home != "" {
15+ dirPath = home
16+ } else {
17 if filepath.Separator != '/' {
18 return cs
19 }
20 dirPath = "/"
21- } else {
22- dirPath = home
23 }
24- } else if strings.HasSuffix(path, string(filepath.Separator)) {
25- dirPath = path
26 } else {
27- dirPath = filepath.Dir(path)
28- dirPrefix = filepath.Base(path)
29+ if home != "" && !filepath.IsAbs(path) {
30+ path = filepath.Join(home, path)
31+ }
32+ if strings.HasSuffix(path, string(filepath.Separator)) {
33+ dirPath = path
34+ } else {
35+ dirPath = filepath.Dir(path)
36+ dirPrefix = filepath.Base(path)
37+ }
38 }
39 dir, err := os.ReadDir(dirPath)
40 if err != nil {