From de6b2fa8cea2bc2edd84a1db7a715776d237d2a9 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Mon, 1 Feb 2016 19:47:25 -0500 Subject: Do not assume 1 byte char widths in Lua pattern find; modules/textadept/find.lua Eventually UTF-8 patterns may be possible. --- modules/textadept/find.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 4c89ce7c..ea6a287e 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -160,7 +160,8 @@ local function find_(text, next, flags, no_wrap, wrapped) local caps = {buffer:text_range(s, e):find(next and patt or '^.*()'..patt)} M.captures = {table.unpack(caps, next and 3 or 4)} if #caps > 0 and caps[2] >= caps[1] then - pos, e = s + caps[next and 1 or 3] - 1, s + caps[2] + pos = buffer:position_relative(s, caps[next and 1 or 3] - 1) + e = buffer:position_relative(s, caps[2]) M.captures[0] = buffer:text_range(pos, e) buffer:set_sel(e, pos) end -- cgit v1.2.3