aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
Diffstat (limited to 'modules/textadept')
-rw-r--r--modules/textadept/find.lua32
-rw-r--r--modules/textadept/run.lua36
2 files changed, 24 insertions, 44 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index 8187954e..989c84c8 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -18,7 +18,7 @@ find.in_files_label_text = L('In files')
local MARK_FIND = _SCINTILLA.next_marker_number()
local MARK_FIND_COLOR = 0x4D9999
-local prev_view
+local preferred_view
-- Text escape sequences with their associated characters.
-- @class table
@@ -62,7 +62,7 @@ function find.find_in_files(utf8_dir)
function search_dir(directory)
for file in lfs_dir(directory) do
if not file:find('^%.%.?$') then -- ignore . and ..
- local path = directory..'/'..file
+ local path = directory..(not WIN32 and '/' or '\\')..file
local type = lfs_attributes(path, 'mode')
if type == 'directory' then
search_dir(path)
@@ -76,9 +76,7 @@ function find.find_in_files(utf8_dir)
search_dir(dir)
if #matches == 1 then matches[2] = L('No results found') end
matches[#matches + 1] = ''
- if buffer._type ~= L('[Files Found Buffer]') then
- prev_view = _VIEWS[view]
- end
+ if buffer._type ~= L('[Files Found Buffer]') then preferred_view = view end
gui._print(L('[Files Found Buffer]'), table.concat(matches, '\n'))
end
end
@@ -300,7 +298,6 @@ local function replace_all(ftext, rtext, flags)
end
events.connect(events.REPLACE_ALL, replace_all)
--- TODO: refactor?
-- When the user double-clicks a found file, go to the line in the file the text
-- was found at.
-- @param pos The position of the caret.
@@ -314,27 +311,8 @@ local function goto_file(pos, line_num)
buffer:marker_set_back(MARK_FIND, MARK_FIND_COLOR)
buffer:marker_add(line_num, MARK_FIND)
buffer:goto_pos(buffer.current_pos)
- if #_VIEWS == 1 then
- view:split()
- prev_view = 2 -- second view
- else
- local clicked_view = view
- if prev_view then gui.goto_view(prev_view) end
- if buffer._type == L('[Files Found Buffer]') then
- -- There are at least two find in files views; find one of those views
- -- that the file was not selected from and focus it.
- for i, v in ipairs(_VIEWS) do
- if v ~= clicked_view then
- prev_view = i
- gui.goto_view(i)
- break
- end
- end
- end
- end
- io.open_file(file)
- buffer:ensure_visible_enforce_policy(file_line_num - 1)
- buffer:goto_line(file_line_num - 1)
+ gui.goto_file(file, true, preferred_view)
+ _m.textadept.editing.goto_line(file_line_num)
end
end
end
diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua
index 39a71db1..8e1561f3 100644
--- a/modules/textadept/run.lua
+++ b/modules/textadept/run.lua
@@ -135,24 +135,26 @@ error_detail = {}
-- @param line_num The line double-clicked.
-- @see error_detail
function goto_error(pos, line_num)
- local type = buffer._type
- if type == L('[Message Buffer]') or type == L('[Error Buffer]') then
- line = buffer:get_line(line_num)
- for _, error_detail in pairs(error_detail) do
- local captures = { line:match(error_detail.pattern) }
- if #captures > 0 then
- local utf8_filename = captures[error_detail.filename]
- local filename = utf8_filename:iconv(_CHARSET, 'UTF-8')
- if lfs.attributes(filename) then
- io.open_file(utf8_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('"%s" %s', utf8_filename, L('does not exist')))
- end
- break
+ if buffer._type ~= L('[Message Buffer]') and
+ buffer._type ~= L('[Error Buffer]') then
+ return
+ end
+ local buffer = buffer
+ line = buffer:get_line(line_num)
+ for _, error_detail in pairs(error_detail) do
+ local captures = { line:match(error_detail.pattern) }
+ if #captures > 0 then
+ local utf8_filename = captures[error_detail.filename]
+ local filename = utf8_filename:iconv(_CHARSET, 'UTF-8')
+ if lfs.attributes(filename) then
+ gui.goto_file(utf8_filename, true)
+ _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('"%s" %s', utf8_filename, L('does not exist')))
end
+ return
end
end
end