Fix reload module problem on windows
This commit is contained in:
parent
6369a7f760
commit
1ce1c114ba
|
@ -67,7 +67,7 @@ end
|
||||||
|
|
||||||
local function save(filename)
|
local function save(filename)
|
||||||
doc():save(filename)
|
doc():save(filename)
|
||||||
if doc().filename == (USERDIR .. PATHSEP .. "init.lua") then
|
if doc().filename == common.normalize_path(USERDIR .. PATHSEP .. "init.lua") then
|
||||||
core.reload_module("core.style")
|
core.reload_module("core.style")
|
||||||
core.load_user_directory()
|
core.load_user_directory()
|
||||||
end
|
end
|
||||||
|
|
|
@ -228,4 +228,14 @@ function common.home_expand(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function common.normalize_path(filename)
|
||||||
|
if PATHSEP == '\\' then
|
||||||
|
filename = filename:gsub('[/\\]', '\\')
|
||||||
|
local drive, rem = filename:match('^([a-zA-Z])(:.*)')
|
||||||
|
return drive and drive:upper() .. rem or filename
|
||||||
|
end
|
||||||
|
return filename
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return common
|
return common
|
||||||
|
|
|
@ -67,6 +67,7 @@ end
|
||||||
|
|
||||||
function Doc:load(filename)
|
function Doc:load(filename)
|
||||||
local fp = assert( io.open(filename, "rb") )
|
local fp = assert( io.open(filename, "rb") )
|
||||||
|
filename = common.normalize_path(filename)
|
||||||
self:reset()
|
self:reset()
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.lines = {}
|
self.lines = {}
|
||||||
|
@ -93,7 +94,7 @@ function Doc:save(filename)
|
||||||
fp:write(line)
|
fp:write(line)
|
||||||
end
|
end
|
||||||
fp:close()
|
fp:close()
|
||||||
self.filename = filename or self.filename
|
self.filename = common.normalize_path(filename or self.filename)
|
||||||
self:reset_syntax()
|
self:reset_syntax()
|
||||||
self:clean()
|
self:clean()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue