Skip to content

Commit

Permalink
findinfiles: Skip empty strings when building file pattern regexp
Browse files Browse the repository at this point in the history
When building the regexp for file patterns when exclude_re is
false, skip empty strings.

This fixes issue spyder-ide#7811 when exclude_re is false.
  • Loading branch information
ehabkost committed Sep 2, 2018
1 parent d1f925d commit a10a893
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spyder/widgets/findinfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ def get_options(self, all=False):

if not exclude_re:
items = [fnmatch.translate(item.strip())
for item in exclude.split(",")]
for item in exclude.split(",")
if item.strip() != '']
exclude = '|'.join(items)

# Validate regular expressions:
Expand Down
12 changes: 12 additions & 0 deletions spyder/widgets/tests/test_findinfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ def test_exclude_extension_empty_regex(qtbot):
assert expected_results() == matches


def test_exclude_extension_string(qtbot):
find_in_files = setup_findinfiles(qtbot, exclude="",
exclude_regexp=False)
find_in_files.set_search_text("spam")
find_in_files.find_options.set_directory(osp.join(LOCATION, "data"))
find_in_files.find()
blocker = qtbot.waitSignal(find_in_files.sig_finished)
blocker.wait()
matches = process_search_results(find_in_files.result_browser.data)
assert expected_results() == matches


def test_exclude_extension_multiple_string(qtbot):
find_in_files = setup_findinfiles(qtbot, exclude="*.py, *.cpp",
exclude_regexp=False)
Expand Down

0 comments on commit a10a893

Please sign in to comment.