Merge pull request #377 from adamharrison/regex-anchored
Fixed small bug on bootup, and added in a multiline qualifier to replacements.
This commit is contained in:
commit
d9fc6d407b
|
@ -29,8 +29,8 @@ local function get_find_tooltip()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update_preview(sel, search_fn, text)
|
local function update_preview(sel, search_fn, text)
|
||||||
local ok, line1, col1, line2, col2 =
|
local ok, line1, col1, line2, col2 = pcall(search_fn, last_view.doc,
|
||||||
pcall(search_fn, last_view.doc, sel[1], sel[2], text, case_sensitive, find_regex)
|
sel[1], sel[2], text, case_sensitive, find_regex)
|
||||||
if ok and line1 and text ~= "" then
|
if ok and line1 and text ~= "" then
|
||||||
last_view.doc:set_selection(line2, col2, line1, col1)
|
last_view.doc:set_selection(line2, col2, line1, col1)
|
||||||
last_view:scroll_to_line(line2, true)
|
last_view:scroll_to_line(line2, true)
|
||||||
|
@ -116,7 +116,7 @@ command.add("core.docview", {
|
||||||
if not find_regex then
|
if not find_regex then
|
||||||
return text:gsub(old:gsub("%W", "%%%1"), new:gsub("%%", "%%%%"), nil)
|
return text:gsub(old:gsub("%W", "%%%1"), new:gsub("%%", "%%%%"), nil)
|
||||||
end
|
end
|
||||||
local result, matches = regex.gsub(regex.compile(old), text, new)
|
local result, matches = regex.gsub(regex.compile(old, "m"), text, new)
|
||||||
return result, #matches
|
return result, #matches
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
|
@ -180,12 +180,12 @@ command.add("core.commandview", {
|
||||||
["find-replace:toggle-sensitivity"] = function()
|
["find-replace:toggle-sensitivity"] = function()
|
||||||
case_sensitive = not case_sensitive
|
case_sensitive = not case_sensitive
|
||||||
core.status_view:show_tooltip(get_find_tooltip())
|
core.status_view:show_tooltip(get_find_tooltip())
|
||||||
update_preview(last_sel, last_fn, last_text)
|
if last_sel then update_preview(last_sel, last_fn, last_text) end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["find-replace:toggle-regex"] = function()
|
["find-replace:toggle-regex"] = function()
|
||||||
find_regex = not find_regex
|
find_regex = not find_regex
|
||||||
core.status_view:show_tooltip(get_find_tooltip())
|
core.status_view:show_tooltip(get_find_tooltip())
|
||||||
update_preview(last_sel, last_fn, last_text)
|
if last_sel then update_preview(last_sel, last_fn, last_text) end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue