From a417ec4dcbeab6a78c7fb3b6bd13190fb8f8a51c Mon Sep 17 00:00:00 2001 From: Ali Kefia Date: Wed, 25 Aug 2021 22:26:54 +0200 Subject: [PATCH] normalize path - force slash separator to access embed FS (#2197) --- .gitignore | 1 - runtime/runtime.go | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 62f97acf..2adb8d5f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,5 @@ benchmark_results* tools/build-version tools/build-date tools/info-plist -tools/bindata tools/vscode-tests/ *.hdr diff --git a/runtime/runtime.go b/runtime/runtime.go index c71124cd..5dc46a67 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -2,6 +2,7 @@ package config import ( "embed" + "path/filepath" "strings" ) @@ -10,9 +11,13 @@ import ( //go:embed colorschemes help plugins syntax var runtime embed.FS +func fixPath(name string) string { + return strings.TrimLeft(filepath.ToSlash(name), "runtime/") +} + // AssetDir lists file names in folder func AssetDir(name string) ([]string, error) { - name = strings.TrimLeft(name, "runtime/") + name = fixPath(name) entries, err := runtime.ReadDir(name) if err != nil { return nil, err @@ -26,6 +31,6 @@ func AssetDir(name string) ([]string, error) { // Asset returns a file content func Asset(name string) ([]byte, error) { - name = strings.TrimLeft(name, "runtime/") + name = fixPath(name) return runtime.ReadFile(name) } -- 2.44.0