From 4aae314e67116f73fdbf309d23f15ab8dcf1156c Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sat, 8 Aug 2020 22:14:47 -0400 Subject: Use comma-separated patterns in find & replace pane's "Filter" field. --- doc/manual.md | 2 +- modules/textadept/find.lua | 6 +++--- test/test.lua | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/manual.md b/doc/manual.md index 3276c76d..3992c07d 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -763,7 +763,7 @@ result jumps to it in the file, as do the the `Ctrl+Alt+G` and `Ctrl+Alt+Shift+G` (`^⌘G` and `^⌘⇧G` | none) key bindings for cycling through results. -A filter consists of a semicolon-separated list of [Lua patterns](#Lua.Patterns) +A filter consists of a comma-separated list of [Lua patterns](#Lua.Patterns) that match filenames and directories to include or exclude. Patterns are inclusive by default. Exclusive patterns begin with a '!'. If no inclusive patterns are given, any filename is initially considered. As a convenience, diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 7a885825..979a08d6 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -130,7 +130,7 @@ function M.focus(options) repl_text = M.replace_entry_text -- save local filter = M.find_in_files_filters[ff_dir()] or lfs.default_filter M.replace_entry_text = type(filter) == 'string' and filter or - table.concat(filter, ';') + table.concat(filter, ',') elseif repl_text and M.replace_entry_text ~= repl_text then M.replace_entry_text = repl_text -- restore end @@ -283,7 +283,7 @@ function M.find_in_files(dir, filter) if M.replace_entry_text ~= repl_text then -- Update stored filter. local t = {} - for patt in M.replace_entry_text:gmatch('[^;]+') do t[#t + 1] = patt end + for patt in M.replace_entry_text:gmatch('[^,]+') do t[#t + 1] = patt end M.find_in_files_filters[dir], M.find_in_files_filters[ff_dir()] = t, t end filter = M.find_in_files_filters[dir] or lfs.default_filter @@ -294,7 +294,7 @@ function M.find_in_files(dir, filter) ui._print(_L['[Files Found Buffer]'], string.format( '%s %s\n%s %s', _L['Find:']:gsub('_', ''), M.find_entry_text, _L['Filter:']:gsub('_', ''), - type(filter) == 'string' and filter or table.concat(filter, ';'))) + type(filter) == 'string' and filter or table.concat(filter, ','))) buffer.indicator_current = M.INDIC_FIND -- Determine which files to search. diff --git a/test/test.lua b/test/test.lua index 2c71c3a4..0c46691e 100644 --- a/test/test.lua +++ b/test/test.lua @@ -2301,15 +2301,15 @@ function test_ui_find_find_in_files_interactive() assert(results:find('Filter: /test\n'), 'no filter defined') assert(results:find('src/foo.c'), 'foo.c not found') assert(results:find('include/foo.h'), 'foo.h not found') - assert_equal(table.concat(ui.find.find_in_files_filters[_HOME], ';'), '/test') + assert_equal(table.concat(ui.find.find_in_files_filters[_HOME], ','), '/test') buffer:clear_all() - ui.find.replace_entry_text = '/test;.c' + ui.find.replace_entry_text = '/test,.c' events.emit(events.FIND, ui.find.find_entry_text, true) results = buffer:get_text() - assert(results:find('Filter: /test;.c\n'), 'no filter defined') + assert(results:find('Filter: /test,.c\n'), 'no filter defined') assert(results:find('src/foo.c'), 'foo.c not found') assert(not results:find('include/foo.h'), 'foo.h found') - assert_equal(table.concat(ui.find.find_in_files_filters[_HOME], ';'), '/test;.c') + assert_equal(table.concat(ui.find.find_in_files_filters[_HOME], ','), '/test,.c') if not CURSES then -- Verify save and restore of replacement text and directory filters. ui.find.focus{in_files = false} @@ -2317,7 +2317,7 @@ function test_ui_find_find_in_files_interactive() ui.find.replace_entry_text = 'bar' ui.find.focus{in_files = true} assert_equal(ui.find.in_files, true) - assert_equal(ui.find.replace_entry_text, '/test;.c') + assert_equal(ui.find.replace_entry_text, '/test,.c') ui.find.focus{in_files = false} assert_equal(ui.find.replace_entry_text, 'bar') end @@ -2444,21 +2444,21 @@ function test_macro_record_play_with_keys_only() buffer:new_line() events.emit(events.KEYPRESS, not CURSES and 0xFF54 or 300) -- down events.emit(events.KEYPRESS, 0xFFC6) -- f9; stop recording - assert_equal(buffer:get_text(), 'foo\n\nbar\nbaz\n'); + assert_equal(buffer:get_text(), 'foo\n\nbar\nbaz\n') assert_equal(buffer.current_pos, buffer:position_from_line(3)) if not CURSES then events.emit(events.KEYPRESS, 0xFFC6, true) -- sf9; play else events.emit(events.KEYPRESS, 0xFFC7) -- f10; play end - assert_equal(buffer:get_text(), 'foo\n\nbar\n\nbaz\n'); + assert_equal(buffer:get_text(), 'foo\n\nbar\n\nbaz\n') assert_equal(buffer.current_pos, buffer:position_from_line(5)) if not CURSES then events.emit(events.KEYPRESS, 0xFFC6, true) -- sf9; play else events.emit(events.KEYPRESS, 0xFFC7) -- f10; play end - assert_equal(buffer:get_text(), 'foo\n\nbar\n\nbaz\n\n'); + assert_equal(buffer:get_text(), 'foo\n\nbar\n\nbaz\n\n') assert_equal(buffer.current_pos, buffer:position_from_line(7)) buffer:close(true) end @@ -3023,7 +3023,7 @@ function test_ansi_c_autocomplete() buffer.new() buffer:set_lexer('ansi_c') - buffer:add_text('str'); + buffer:add_text('str') textadept.editing.autocomplete('ansi_c') assert(buffer:auto_c_active(), 'no autocompletions') assert_equal(buffer.auto_c_current_text, 'strcat') -- cgit v1.2.3