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
|
if f then
|
||||||
local chars = 0
|
local chars = 0
|
||||||
for _, line in ipairs(buffer) do
|
for _, line in ipairs(buffer) do
|
||||||
|
if chars > 0 then
|
||||||
|
line = line .. "\n"
|
||||||
|
end
|
||||||
f:write(line)
|
f:write(line)
|
||||||
f:write("\n")
|
|
||||||
chars = chars + unicode.len(line)
|
chars = chars + unicode.len(line)
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
@ -330,6 +332,9 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
|
if #buffer == 0 then
|
||||||
|
table.insert(buffer, "")
|
||||||
|
end
|
||||||
local format
|
local format
|
||||||
if readonly then
|
if readonly then
|
||||||
format = [["%s" [readonly] %dL,%dC]]
|
format = [["%s" [readonly] %dL,%dC]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user