Skip to content

Commit

Permalink
findinfiles: Ignore exclude regexp if it's empty
Browse files Browse the repository at this point in the history
If the exclude regexp is empty, don't try to compile it. Change
SearchThread so an empty string will make no file be excluded
from the search.

This fixes issue spyder-ide#7811 when exclude_re is true.

Signed-off-by: Eduardo Habkost <ehabkost@raisama.net>
  • Loading branch information
ehabkost committed Sep 2, 2018
1 parent bda2fff commit dd9dae9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions spyder/widgets/findinfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def initialize(self, path, is_file, exclude,
self.rootpath = path
self.python_path = False
self.hg_manifest = False
self.exclude = re.compile(exclude)
if exclude:
self.exclude = re.compile(exclude)
self.texts = texts
self.text_re = text_re
self.is_file = is_file
Expand Down Expand Up @@ -143,14 +144,14 @@ def find_files_in_path(self, path):
if self.stopped:
return False
dirname = os.path.join(path, d)
if re.search(self.exclude, dirname + os.sep):
if self.exclude and re.search(self.exclude, dirname + os.sep):
dirs.remove(d)
for f in files:
with QMutexLocker(self.mutex):
if self.stopped:
return False
filename = os.path.join(path, f)
if re.search(self.exclude, filename):
if self.exclude and re.search(self.exclude, filename):
continue
if is_text_file(filename):
self.find_string_in_file(filename)
Expand Down Expand Up @@ -565,7 +566,8 @@ def get_options(self, all=False):
# Validate regular expressions:

try:
exclude = re.compile(exclude)
if exclude:
exclude = re.compile(exclude)
except Exception:
exclude_edit = self.exclude_pattern.lineEdit()
exclude_edit.setStyleSheet(self.REGEX_INVALID)
Expand Down

0 comments on commit dd9dae9

Please sign in to comment.