From dd9dae9b2df536d0d778d535a3d5166f17941ac8 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Sat, 1 Sep 2018 17:56:28 -0300 Subject: [PATCH] findinfiles: Ignore exclude regexp if it's empty 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 #7811 when exclude_re is true. Signed-off-by: Eduardo Habkost --- spyder/widgets/findinfiles.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spyder/widgets/findinfiles.py b/spyder/widgets/findinfiles.py index 2bbb4dc9dd1..e33edc0c0b7 100644 --- a/spyder/widgets/findinfiles.py +++ b/spyder/widgets/findinfiles.py @@ -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 @@ -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) @@ -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)