diff options
author | 2011-09-26 18:11:57 -0400 | |
---|---|---|
committer | 2011-09-26 18:11:57 -0400 | |
commit | 8bcdb16e18641e1cea08ebb614d70d98a3c27426 (patch) | |
tree | da922f622a6a03a875625f8905c3fbcb129e8aad /modules/textadept/find.lua | |
parent | c2d73d4284cc5009128bc5fed68fcc5826336ea2 (diff) | |
download | textadept-8bcdb16e18641e1cea08ebb614d70d98a3c27426.tar.gz textadept-8bcdb16e18641e1cea08ebb614d70d98a3c27426.zip |
Lua code cleanup.
Diffstat (limited to 'modules/textadept/find.lua')
-rw-r--r-- | modules/textadept/find.lua | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 409ffe4c..8debc7ec 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -238,8 +238,7 @@ local function replace(rtext) local captures = find.captures if captures then for i = 1, #captures do - local v = captures[i]:gsub('%%', '%%%%') -- escape '%' for gsub - rtext = rtext:gsub('%%'..i, v) + rtext = rtext:gsub('%%'..i, captures[i]:gsub('%%', '%%%%')) end end local ok, rtext = pcall(rtext.gsub, rtext, '%%(%b())', run) @@ -301,6 +300,7 @@ 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. @@ -354,10 +354,8 @@ function find.goto_file_in_list(next) line = line + (next and 1 or -1) if line > buffer.line_count - 1 then line = 0 end if line < 0 then line = buffer.line_count - 1 end - if line == orig_line then -- prevent infinite loops - gui.goto_view(orig_view) - return - end + -- Prevent infinite loops. + if line == orig_line then gui.goto_view(orig_view) return end if buffer:get_line(line):match('^(.+):(%d+):.+$') then buffer:goto_line(line) goto_file(buffer.current_pos, line) @@ -371,5 +369,6 @@ function find.goto_file_in_list(next) end if buffer then buffer:marker_set_back(MARK_FIND, MARK_FIND_COLOR) end -events.connect(events.VIEW_NEW, - function() buffer:marker_set_back(MARK_FIND, MARK_FIND_COLOR) end) +events.connect(events.VIEW_NEW, function() + buffer:marker_set_back(MARK_FIND, MARK_FIND_COLOR) +end) |