aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2013-03-28 21:36:58 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2013-03-28 21:36:58 -0400
commit91ee21cf2cc25547908635af788e7955bfae030b (patch)
tree139426aefc5d8a0b56558908668313f796f663b2
parent2fb60bd197071eb6c1da78e65e00aaaa374bdce1 (diff)
Improved message double-clicking behavior for compile and run commands.
Added `_M.textadept.run.cwd` field for storing the working directory for more accurate relative file paths.
-rw-r--r--core/gui.lua6
-rw-r--r--modules/textadept/run.lua6
2 files changed, 10 insertions, 2 deletions
diff --git a/core/gui.lua b/core/gui.lua
index e6ccb9aa..f61a45b3 100644
--- a/core/gui.lua
+++ b/core/gui.lua
@@ -139,7 +139,11 @@ end
-- `false`.
-- @name goto_file
function gui.goto_file(filename, split, preferred_view, sloppy)
- local patt = not sloppy and '^'..filename..'$' or filename..'$'
+ local patt = '^'..filename..'$'
+ if sloppy then
+ local i = filename:reverse():find('[/\\]%.%.?') -- ./ or ../
+ patt = i and filename:sub(-i + 1, -1)..'$' or filename..'$'
+ end
if #_VIEWS == 1 and split and not (view.buffer.filename or ''):find(patt) then
view:split()
else
diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua
index fd0bffbe..38eb6301 100644
--- a/modules/textadept/run.lua
+++ b/modules/textadept/run.lua
@@ -10,6 +10,9 @@ local M = {}
-- extension.
--
-- [language-specific modules]: _M.html#Compile.and.Run
+-- @field cwd (string, Read-only)
+-- The working directory for the most recently executed compile or run
+-- command.
-- @field _G.events.COMPILE_OUTPUT (string)
-- Called after executing a language's compile command.
-- By default, compiler output is printed to the message buffer. To override
@@ -70,6 +73,7 @@ local function command(cmd_table, compiling)
end
local ok, status, code = p:close()
if ok and code then events_emit(event, lexer, status..': '..code) end
+ M.cwd = filedir
lfs.chdir(current_dir)
end
@@ -203,7 +207,7 @@ function goto_error(pos, line_num)
end
local error_details = get_error_details(buffer:get_line(line_num))
if not error_details then return end
- gui.goto_file(error_details.filename, true, preferred_view, true)
+ gui.goto_file(M.cwd..error_details.filename, true, preferred_view, true)
local line, message = error_details.line, error_details.message
buffer:goto_line(line - 1)
if message then