File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,13 @@ local function path_resolve_dot(path)
141141 return (is_path_absolute and " /" or " " ) .. table.concat (new_path_components , " /" )
142142end
143143
144- local user = uv .os_get_passwd ().username
144+ local ok , passwd = pcall (uv .os_get_passwd )
145+ --- @type string ?
146+ local user
147+ if ok then
148+ user = passwd .username
149+ end
150+
145151local path_segment_ends = { " /" , " \\ " , " " }
146152--- @param path string
147153--- @param i integer
@@ -169,7 +175,7 @@ function compat.fs_normalize(path, opts)
169175
170176 if path_segment_ends_at (path , 2 ) then
171177 path = home .. path :sub (2 )
172- elseif vim .startswith (path , " ~" .. user ) and path_segment_ends_at (path , 2 + # user ) then
178+ elseif user and vim .startswith (path , " ~" .. user ) and path_segment_ends_at (path , 2 + # user ) then
173179 path = home .. path :sub (# user + 2 ) --- @type string
174180 end
175181 end
You can’t perform that action at this time.
0 commit comments