aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-08-23 17:42:33 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-08-23 17:42:33 -0400
commite326775782bc8b9b0e004d5134d602b26ffeb3a5 (patch)
tree54a56d3fb978a39ea4932cb86362ebe4589e1a11
parenta4ca21792b915781b69b3ece14a7a5f67595693c (diff)
downloadtextadept-e326775782bc8b9b0e004d5134d602b26ffeb3a5.tar.gz
textadept-e326775782bc8b9b0e004d5134d602b26ffeb3a5.zip
Fixed bug where jumping to a find in files result of length 1 highlights wrong.
-rw-r--r--modules/textadept/find.lua2
-rw-r--r--test/test.lua15
2 files changed, 14 insertions, 3 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index ffc4d2b2..231159e2 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -467,7 +467,7 @@ function M.goto_file_found(line_num, next)
textadept.editing.select_line()
pos = buffer.selection_start + pos - 1 -- absolute pos of result text on line
local s = buffer:indicator_end(M.INDIC_FIND, buffer.selection_start)
- local e = buffer:indicator_end(M.INDIC_FIND, s + 1)
+ local e = buffer:indicator_end(M.INDIC_FIND, s)
if buffer:line_from_position(s) == buffer:line_from_position(pos) then
s, e = s - pos, e - pos -- relative to line start
else
diff --git a/test/test.lua b/test/test.lua
index 7e7894af..001124e4 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -2276,7 +2276,7 @@ function test_ui_find_find_in_files()
assert(count > 0, 'no files found')
local s = buffer:indicator_end(ui.find.INDIC_FIND, 0)
while true do
- local e = buffer:indicator_end(ui.find.INDIC_FIND, s + 1)
+ local e = buffer:indicator_end(ui.find.INDIC_FIND, s)
if e == s then break end -- no more results
assert_equal(buffer:text_range(s, e), 'foo')
s = buffer:indicator_end(ui.find.INDIC_FIND, e + 1)
@@ -2347,10 +2347,21 @@ function test_ui_find_find_in_files_interactive()
buffer:close()
ui.goto_view(1)
view:unsplit()
- buffer:close()
ui.find.find_in_files_filters[_HOME] = filter
end
+function test_ui_find_in_files_single_char()
+ ui.find.find_entry_text = 'z'
+ ui.find.find_in_files(_HOME .. '/test')
+ ui.find.goto_file_found(true)
+ assert_equal(buffer:get_sel_text(), 'z')
+ ui.find.find_entry_text = ''
+ buffer:close()
+ ui.goto_view(1)
+ view:unsplit()
+ buffer:close()
+end
+
function test_ui_find_replace()
buffer.new()
buffer:set_text('foofoo')