Skip to content

Commit 4e22235

Browse files
committed
limit 'compare to files in project' to 1000 files (settings: 'limit')
1 parent 0f193e0 commit 4e22235

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

file_diffs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,14 @@ def on_done(index):
237237
**kwargs)
238238
sublime.set_timeout(lambda: self.view.window().show_quick_panel(file_picker, on_done), 1)
239239

240-
def find_files(self, folders):
240+
def find_files(self, folders, ret=[]):
241241
# Cannot access these settings!! WHY!?
242242
# folder_exclude_patterns = self.view.settings().get('folder_exclude_patterns')
243243
# file_exclude_patterns = self.view.settings().get('file_exclude_patterns')
244244
folder_exclude_patterns = [".svn", ".git", ".hg", "CVS"]
245245
file_exclude_patterns = ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj", "*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", "*.class", "*.psd", "*.db"]
246+
max_files = self.settings().get('limit', 1000)
246247

247-
ret = []
248248
for folder in folders:
249249
if not os.path.isdir(folder):
250250
continue
@@ -254,11 +254,14 @@ def find_files(self, folders):
254254
if os.path.isdir(fullpath):
255255
# excluded folder?
256256
if not len([True for pattern in folder_exclude_patterns if fnmatch(file, pattern)]):
257-
ret += self.find_files([fullpath])
257+
self.find_files([fullpath], ret)
258258
else:
259259
# excluded file?
260260
if not len([True for pattern in file_exclude_patterns if fnmatch(file, pattern)]):
261261
ret.append(fullpath)
262+
if len(ret) >= max_files:
263+
sublime.status_message('Too many files to include all of them in this list')
264+
return ret
262265
return ret
263266

264267

0 commit comments

Comments
 (0)