Skip to content

Commit 5f37370

Browse files
authored
Merge pull request #2893 from sparr/add_storagePath_option
Add storagePath handling and memoization to resolvePathPlaceholders
2 parents f6dcbcc + 4b6540d commit 5f37370

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
55
* `FIX` Fixed an issue preventing to set the locale to Japanese
6+
* `FIX` Accept storagePath option from client to resolve addon directory not found
67

78
## 3.11.0
89
* `NEW` Added support for Japanese locale

script/files.lua

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,8 @@ function m.countStates()
906906
return n
907907
end
908908

909+
local addonsPath
910+
909911
---Resolve path variables/placeholders like ${3rd} and ${addons}
910912
---@param path string
911913
---@return string resolvedPath
@@ -914,22 +916,32 @@ function m.resolvePathPlaceholders(path)
914916
if key == "3rd" then
915917
return (ROOT / "meta" / "3rd"):string()
916918
elseif key == "addons" then
917-
-- Common path across OSes
918-
local dataPath = "User/globalStorage/sumneko.lua/addonManager/addons"
919-
920-
if platform.os == "windows" then
921-
return "$APPDATA/Code/" .. dataPath
922-
elseif platform.os == "linux" then
923-
local serverPath = util.expandPath(fs.path("~/.vscode-server/data"):string())
924-
if fs.exists(serverPath) then
925-
-- addons are installed via SSH remote
926-
return serverPath .."/" .. dataPath
927-
else
928-
return "~/.config/Code/" .. dataPath
919+
if addonsPath then
920+
return addonsPath
921+
end
922+
local client = require 'client'
923+
local storagePath = client.getOption('storagePath')
924+
if storagePath then
925+
addonsPath = storagePath .. "/addonManager/addons"
926+
else
927+
-- Common path across OSes
928+
local dataPath = "User/globalStorage/sumneko.lua/addonManager/addons"
929+
930+
if platform.os == "windows" then
931+
addonsPath = "$APPDATA/Code/" .. dataPath
932+
elseif platform.os == "linux" then
933+
local serverPath = util.expandPath(fs.path("~/.vscode-server/data"):string())
934+
if fs.exists(serverPath) then
935+
-- addons are installed via SSH remote
936+
addonsPath = serverPath .."/" .. dataPath
937+
else
938+
addonsPath = "~/.config/Code/" .. dataPath
939+
end
940+
elseif platform.os == "macos" then
941+
addonsPath = "~/Library/Application Support/Code/" .. dataPath
929942
end
930-
elseif platform.os == "macos" then
931-
return "~/Library/Application Support/Code/" .. dataPath
932943
end
944+
return addonsPath
933945
elseif key:sub(1, 4) == "env:" then
934946
local env = os.getenv(key:sub(5))
935947
return env

0 commit comments

Comments
 (0)