diff options
author | 2012-03-25 12:26:29 -0400 | |
---|---|---|
committer | 2012-03-25 12:26:29 -0400 | |
commit | 50ee1f80ae539185f1d72ece6660b80997f0b2c2 (patch) | |
tree | 6dac5f0e6da220741b1f1fab3296b058b21374ee /core/gui.lua | |
parent | 1329e9cd55f2741d1d8924b416b1646c23e7dee0 (diff) | |
download | textadept-50ee1f80ae539185f1d72ece6660b80997f0b2c2.tar.gz textadept-50ee1f80ae539185f1d72ece6660b80997f0b2c2.zip |
Improved message double-clicking behavior for run and compile commands.
Diffstat (limited to 'core/gui.lua')
-rw-r--r-- | core/gui.lua | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/core/gui.lua b/core/gui.lua index f97ace83..5be51813 100644 --- a/core/gui.lua +++ b/core/gui.lua @@ -122,18 +122,27 @@ end -- other view. -- @param preferred_view When multiple views exist and the desired buffer is not -- open in any of them, open it in this one. +-- @param sloppy Flag indicating whether or not to not match `filename` to +-- `buffer.filename` exactly. When `true`, matches `filename` to only the last +-- part of `buffer.filename` This is useful for run and compile commands which +-- output relative filenames and paths instead of full ones and it is likely +-- that the file in question is already open. The default value is `false`. -- @name goto_file -function gui.goto_file(filename, split, preferred_view) - if #_VIEWS == 1 and view.buffer.filename ~= filename and split then +function gui.goto_file(filename, split, preferred_view, sloppy) + local patt = not sloppy and '^'..filename..'$' or filename..'$' + if #_VIEWS == 1 and split and not (view.buffer.filename or ''):find(patt) then view:split() else local other_view = _VIEWS[preferred_view] for i, v in ipairs(_VIEWS) do - if v.buffer.filename == filename then gui.goto_view(i) return end + if (v.buffer.filename or ''):find(patt) then gui.goto_view(i) return end if not other_view and v ~= view then other_view = i end end if other_view then gui.goto_view(other_view) end end + for i, buffer in ipairs(_BUFFERS) do + if (buffer.filename or ''):find(patt) then view:goto_buffer(i) return end + end io.open_file(filename) end |