diff options
-rw-r--r-- | core/ext/pm/ctags_browser.lua | 4 | ||||
-rw-r--r-- | core/ext/pm/modules_browser.lua | 6 | ||||
-rw-r--r-- | core/ext/pm/project_browser.lua | 6 | ||||
-rw-r--r-- | core/file_io.lua | 10 | ||||
-rw-r--r-- | core/init.lua | 2 | ||||
-rw-r--r-- | modules/lua/commands.lua | 5 | ||||
-rw-r--r-- | modules/textadept/macros.lua | 4 |
7 files changed, 18 insertions, 19 deletions
diff --git a/core/ext/pm/ctags_browser.lua b/core/ext/pm/ctags_browser.lua index 7039d1c4..01f8cc12 100644 --- a/core/ext/pm/ctags_browser.lua +++ b/core/ext/pm/ctags_browser.lua @@ -117,13 +117,13 @@ function get_contents_for(full_path, expanding) current_file = nil current_dir = '' -- ctags file will specify absolute paths os.execute('ctags -f '..FILE_OUT..' '..(buffer.filename or '')) - f = io.open(FILE_OUT) + f = io.open(FILE_OUT, 'rb') if not f then return {} end elseif not expanding then tags = {} current_file = ctags_file current_dir = ctags_file:match('^.+/') -- ctags file dirname - f = io.open(ctags_file) + f = io.open(ctags_file, 'rb') if not f then return {} end else local parent = tags diff --git a/core/ext/pm/modules_browser.lua b/core/ext/pm/modules_browser.lua index 2fbef945..fada137b 100644 --- a/core/ext/pm/modules_browser.lua +++ b/core/ext/pm/modules_browser.lua @@ -141,17 +141,17 @@ function perform_menu_action(menu_id, selected_item) local module_dir = _HOME..'/modules/'..module_name if lfs.mkdir(module_dir) then -- write init.lua from template - local f = io.open(module_dir..'/init.lua', 'w') + local f = io.open(module_dir..'/init.lua', 'wb') local out = INIT:gsub('$1', module_name):gsub('$2', lang_name) f:write(out) f:close() -- write snippets.lua from template - f = io.open(module_dir..'/snippets.lua', 'w') + f = io.open(module_dir..'/snippets.lua', 'wb') out = SNIPPETS:gsub('$1', module_name):gsub('$2', lang_name) f:write(out) f:close() -- write commands.lua from template - f = io.open(module_dir..'/commands.lua', 'w') + f = io.open(module_dir..'/commands.lua', 'wb') out = COMMANDS:gsub('$1', module_name):gsub('$2', lang_name) f:write(out) f:close() diff --git a/core/ext/pm/project_browser.lua b/core/ext/pm/project_browser.lua index 30616ef9..f034e41c 100644 --- a/core/ext/pm/project_browser.lua +++ b/core/ext/pm/project_browser.lua @@ -179,7 +179,7 @@ function perform_menu_action(menu_id, selected_item) if ret == '3' then return end end end - local f = io.open(file, 'w') + local f = io.open(file, 'wb') f:write('') f:close() update_project() @@ -412,7 +412,7 @@ end -- Sets the local 'project_file' and 'project' fields appropriately. -- @param file The project file. load_project = function(file) - local f = io.open(file) + local f = io.open(file, 'rb') project_root = loadstring('return '..f:read('*all'))() f:close() project_file = file @@ -436,7 +436,7 @@ update_project = function() end end end - local f = io.open(project_file, 'w') + local f = io.open(project_file, 'wb') f:write('{\n') write_folder(project_root, f) f:write('}') diff --git a/core/file_io.lua b/core/file_io.lua index 7500667c..59017b64 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -76,7 +76,7 @@ end function reload(buffer) textadept.check_focused_buffer(buffer) if not buffer.filename then return end - local f, err = io.open(buffer.filename) + local f, err = io.open(buffer.filename, 'rb') if f then local pos = buffer.current_pos local first_visible_line = buffer.first_visible_line @@ -196,7 +196,7 @@ function load_session(filename, only_pm) local user_dir = os.getenv(not WIN32 and 'HOME' or 'USERPROFILE') if not user_dir then return end local ta_session = user_dir..'/.ta_session' - local f = io.open(filename or ta_session) + local f = io.open(filename or ta_session, 'rb') local current_view, splits = 1, { [0] = {} } if f then for line in f:lines() do @@ -204,7 +204,7 @@ function load_session(filename, only_pm) if line:find('^buffer:') then local anchor, current_pos, first_visible_line, filename = line:match('^buffer: (%d+) (%d+) (%d+) (.+)$') - textadept.io.open(filename or '') + textadept.io.open(filename or '', 'rb') -- Restore saved buffer selection and view. local anchor = tonumber(anchor) or 0 local current_pos = tonumber(current_pos) or 0 @@ -314,7 +314,7 @@ function save_session(filename) local user_dir = os.getenv(not WIN32 and 'HOME' or 'USERPROFILE') if not user_dir then return end local ta_session = user_dir..'/.ta_session' - local f = io.open(filename or ta_session, 'w') + local f = io.open(filename or ta_session, 'wb') if f then f:write(table.concat(session, '\n')) f:close() @@ -336,7 +336,7 @@ end -- @usage textadept.io.read_api_file(filename, '%w_') function read_api_file(filename, word_chars) local api = {} - local f = io.open(filename) + local f = io.open(filename, 'rb') if f then for line in f:lines() do local func, params, desc = diff --git a/core/init.lua b/core/init.lua index bf272496..b6d04424 100644 --- a/core/init.lua +++ b/core/init.lua @@ -12,7 +12,7 @@ end _THEME = 'light' local user_dir = os.getenv(not WIN32 and 'HOME' or 'USERPROFILE') if user_dir then - local f = io.open(user_dir..'/.ta_theme') + local f = io.open(user_dir..'/.ta_theme', 'rb') if f then theme = f:read('*line'):match('[^\r\n]+') f:close() diff --git a/modules/lua/commands.lua b/modules/lua/commands.lua index 0b918087..47e872e0 100644 --- a/modules/lua/commands.lua +++ b/modules/lua/commands.lua @@ -55,11 +55,10 @@ function goto_required() end if not file then return end file = file:sub(2, -2):gsub('%.', '/') + local lfs = require 'lfs' for path in package.path:gmatch('[^;]+') do path = path:gsub('?', file) - local f = io.open(path) - if f then - f:close() + if lfs.attributes(file) then textadept.io.open(path) break end diff --git a/modules/textadept/macros.lua b/modules/textadept/macros.lua index 80a89d0f..f45e1fa2 100644 --- a/modules/textadept/macros.lua +++ b/modules/textadept/macros.lua @@ -147,7 +147,7 @@ end -- @param filename The absolute path to the file to save the macros to. function save(filename) if not filename then filename = MACRO_FILE end - local f = assert(io.open(filename, 'w')) + local f = assert(io.open(filename, 'wb')) for name, macro in pairs(list) do f:write(name, '\n') for _, command in ipairs(macro) do @@ -170,7 +170,7 @@ end -- @param filename The absolute path to the file to load the macros from. function load(filename) if not filename then filename = MACRO_FILE end - local f = io.open(filename) + local f = io.open(filename, 'rb') if not f then return end local name, current_macro for line in f:lines() do |