Skip to content

Commit

Permalink
red: abs vs rel cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeping committed Nov 14, 2023
1 parent 2625b4f commit d6dd616
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions data/apps/red.lua
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ function win:path(t, from)
if not to then return t or './' end
if t then
if sys.is_absolute_path(t) then
if not from then
return t
end
to = sys.realpath(t)
else
to = sys.realpath(to .. '/' .. t)
Expand Down Expand Up @@ -333,7 +336,11 @@ function win:exec(t)
end
end

t = self:path(t)
if self.buf:isdir() and sys.is_absolute_path(self.buf.fname) then
t = sys.realpath(self.buf.fname .. t)
else
t = self:path(t)
end

local ff = filename_line(t)
if not sys.isdir(ff) then
Expand All @@ -343,7 +350,7 @@ function win:exec(t)
end
f:close()
elseif self.buf:isdir() then
self.cwd = ff
self.cwd = sys.realpath(ff)
self.buf.fname = (ff .. '/'):gsub("/+", "/")
self:set ""
self:readdir(ff)
Expand Down

0 comments on commit d6dd616

Please sign in to comment.