mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
test: write_file(): support append-mode
This commit is contained in:
@@ -334,8 +334,8 @@ local function feed_command(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Dedent the given text and write it to the file name.
|
-- Dedent the given text and write it to the file name.
|
||||||
local function write_file(name, text, dont_dedent)
|
local function write_file(name, text, no_dedent, append)
|
||||||
local file = io.open(name, 'w')
|
local file = io.open(name, (append and 'a' or 'w'))
|
||||||
if type(text) == 'table' then
|
if type(text) == 'table' then
|
||||||
-- Byte blob
|
-- Byte blob
|
||||||
local bytes = text
|
local bytes = text
|
||||||
@@ -343,7 +343,7 @@ local function write_file(name, text, dont_dedent)
|
|||||||
for _, char in ipairs(bytes) do
|
for _, char in ipairs(bytes) do
|
||||||
text = ('%s%c'):format(text, char)
|
text = ('%s%c'):format(text, char)
|
||||||
end
|
end
|
||||||
elseif not dont_dedent then
|
elseif not no_dedent then
|
||||||
text = dedent(text)
|
text = dedent(text)
|
||||||
end
|
end
|
||||||
file:write(text)
|
file:write(text)
|
||||||
|
|||||||
Reference in New Issue
Block a user