From 6369029ad7f4b9175574027abea15cfc4f6a49a0 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Tue, 27 Jan 2009 21:47:15 -0500 Subject: Do not open a non-existant file from _m.textadept.run.goto_error. --- modules/textadept/run.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua index 9a9901f9..f60bf2b5 100644 --- a/modules/textadept/run.lua +++ b/modules/textadept/run.lua @@ -184,10 +184,17 @@ function goto_error(pos, line_num) for _, error_detail in pairs(error_details) do local captures = { line:match(error_detail.pattern) } if #captures > 0 then - textadept.io.open(captures[error_detail.filename]) - _m.textadept.editing.goto_line(captures[error_detail.line]) - local msg = captures[error_detail.message] - if msg then buffer:call_tip_show(buffer.current_pos, msg) end + local lfs = require 'lfs' + local filename = captures[error_detail.filename] + if lfs.attributes(filename) then + textadept.io.open(filename) + _m.textadept.editing.goto_line(captures[error_detail.line]) + local msg = captures[error_detail.message] + if msg then buffer:call_tip_show(buffer.current_pos, msg) end + else + error(string.format( + textadept.locale.M_TEXTADEPT_RUN_FILE_DOES_NOT_EXIST, filename)) + end break end end -- cgit v1.2.3