Skip to content

Commit caae720

Browse files
committed
Merge upstream PR sindrets#557 from sindrets/diffview.nvim
* pr-557: add `$` to test case on a segment with no corresponding env var fix: only replace path with env var if value defined, otherwise leave $ character in the path
2 parents 55f9519 + 90a72f0 commit caae720

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lua/diffview/path.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ function PathLib:expand(path)
295295

296296
for i = idx, #segments do
297297
local env_var = segments[i]:match("^%$(%S+)$")
298-
if env_var then
299-
segments[i] = uv.os_getenv(env_var) or env_var
298+
if env_var and uv.os_getenv(env_var) ~= nil then
299+
segments[i] = uv.os_getenv(env_var)
300300
end
301301
end
302302

lua/diffview/tests/functional/pathlib_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe("diffview.path", function()
248248
local pl = PathLib({ os = "unix" })
249249

250250
eq("/lorem/ipsum/dolor/foo", pl:expand("~/foo"))
251-
eq("foo/EXPANDED_FOO/EXPANDED_BAR/baz", pl:expand("foo/$VAR_FOO/$VAR_BAR/baz"))
251+
eq("foo/EXPANDED_FOO/EXPANDED_BAR/$baz", pl:expand("foo/$VAR_FOO/$VAR_BAR/$baz"))
252252
end)
253253
end)
254254

0 commit comments

Comments
 (0)