Skip to content

Commit

Permalink
Fix the error message when opening an invalid wg file.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiven committed Jan 22, 2025
1 parent b2bccff commit 6d810f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lua/addons/templates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function Cmd.LoadDefaultTemplate()
local templatename = GlobalSettings.directories.templates.."/default.wg"
local r, e = wg.readfile(templatename)
if r then
local d, e = LoadFromString(r)
local d, e = LoadFromString(templatename, r)
if d then
local fileformat = d.fileformat or 1
if fileformat ~= FILEFORMAT then
Expand Down
4 changes: 2 additions & 2 deletions src/lua/fileio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ function LoadFromHeaderlessString(s)
return loadfromstreamt(CreateIStream(s))
end

function LoadFromString(data: string): (DocumentSet?, string?)
function LoadFromString(filename: string, data: string): (DocumentSet?, string?)
local fp = CreateIStream(data)

local loader = nil
Expand All @@ -620,7 +620,7 @@ function LoadFromFile(filename): (DocumentSet?, string?)
return nil, ("'"..filename.."' could not be opened: "..e)
end
assert(data)
return LoadFromString(data)
return LoadFromString(filename, data)
end

local function loaddocument(filename): (DocumentSet?, string?)
Expand Down

0 comments on commit 6d810f9

Please sign in to comment.