mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
Fix completion for paths starting with /
This commit is contained in:
@@ -23,11 +23,20 @@ func FilePromptCompleter(getcwd func() string) func(string, string) *cli.Complet
|
|||||||
return ans
|
return ans
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return func(before_cursor, after_cursor string) *cli.Completions {
|
return func(before_cursor, after_cursor string) (ans *cli.Completions) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
text, err := utils.Format_stacktrace_on_panic(r)
|
||||||
|
debugprintln(text)
|
||||||
|
debugprintln(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
ans = cli.NewCompletions()
|
||||||
path := before_cursor
|
path := before_cursor
|
||||||
prefix := ""
|
prefix := ""
|
||||||
if idx := strings.Index(path, string(os.PathSeparator)); idx > -1 {
|
if idx := strings.Index(path, string(os.PathSeparator)); idx > -1 {
|
||||||
prefix = filepath.Dir(path) + string(os.PathSeparator)
|
d := filepath.Dir(path)
|
||||||
|
prefix = d + utils.IfElse(strings.HasSuffix(d, string(os.PathSeparator)), "", string(os.PathSeparator))
|
||||||
}
|
}
|
||||||
dir := ""
|
dir := ""
|
||||||
if path == "" {
|
if path == "" {
|
||||||
@@ -46,7 +55,6 @@ func FilePromptCompleter(getcwd func() string) func(string, string) *cli.Complet
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ans := cli.NewCompletions()
|
|
||||||
dirs := ans.AddMatchGroup("Directories")
|
dirs := ans.AddMatchGroup("Directories")
|
||||||
dirs.IsFiles = true
|
dirs.IsFiles = true
|
||||||
dirs.NoTrailingSpace = true
|
dirs.NoTrailingSpace = true
|
||||||
|
|||||||
Reference in New Issue
Block a user