fix: read latest content (#1643)
This commit is contained in:
@@ -179,8 +179,8 @@ function M.read_file(opts, on_log)
|
|||||||
if on_log then on_log("path: " .. abs_path) end
|
if on_log then on_log("path: " .. abs_path) end
|
||||||
local file = io.open(abs_path, "r")
|
local file = io.open(abs_path, "r")
|
||||||
if not file then return "", "file not found: " .. abs_path end
|
if not file then return "", "file not found: " .. abs_path end
|
||||||
local content = file:read("*a")
|
local lines = Utils.read_file_from_buf_or_disk(abs_path)
|
||||||
file:close()
|
local content = lines and table.concat(lines, "\n") or ""
|
||||||
return content, nil
|
return content, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -205,8 +205,8 @@ function M.str_replace_editor(opts, on_log, on_complete)
|
|||||||
if not Path:new(abs_path):is_file() then return false, "Path is not a file: " .. abs_path end
|
if not Path:new(abs_path):is_file() then return false, "Path is not a file: " .. abs_path end
|
||||||
local file = io.open(abs_path, "r")
|
local file = io.open(abs_path, "r")
|
||||||
if not file then return false, "file not found: " .. abs_path end
|
if not file then return false, "file not found: " .. abs_path end
|
||||||
local content = file:read("*a")
|
local lines = Utils.read_file_from_buf_or_disk(abs_path)
|
||||||
file:close()
|
local content = lines and table.concat(lines, "\n") or ""
|
||||||
on_complete(content, nil)
|
on_complete(content, nil)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user