diff options
Diffstat (limited to 'core/file_io.lua')
-rw-r--r-- | core/file_io.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/file_io.lua b/core/file_io.lua index c7433479..e4d36db0 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -53,6 +53,24 @@ function open(filenames) end --- +-- Reloads the file in a given buffer. +-- @param buffer The buffer to reload. This must be the currently focused +-- buffer. +-- @usage buffer:reload() +function reload(buffer) + textadept.check_focused_buffer(buffer) + if not buffer.filename then return end + local f, err = io.open(buffer.filename) + if f then + local pos = buffer.current_pos + buffer:set_text( f:read('*all') ) + buffer.current_pos = pos + buffer:set_save_point() + f:close() + end +end + +--- -- Saves the current buffer to a file. -- @param buffer The buffer to save. Its 'filename' property is used as the -- path of the file to save to. This must be the currently focused buffer. |