mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
fixed edit writing an additional newline after the last line; fixed editor erroring when opening existing but empty files, fixes #39 and closes #43
This commit is contained in:
parent
77d3c1bd1e
commit
d3538a55bc
@ -262,8 +262,10 @@ local function onKeyDown(char, code)
|
||||
if f then
|
||||
local chars = 0
|
||||
for _, line in ipairs(buffer) do
|
||||
if chars > 0 then
|
||||
line = line .. "\n"
|
||||
end
|
||||
f:write(line)
|
||||
f:write("\n")
|
||||
chars = chars + unicode.len(line)
|
||||
end
|
||||
f:close()
|
||||
@ -330,6 +332,9 @@ do
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
if #buffer == 0 then
|
||||
table.insert(buffer, "")
|
||||
end
|
||||
local format
|
||||
if readonly then
|
||||
format = [["%s" [readonly] %dL,%dC]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user