Просмотр исходного кода

Merge pull request #18223 from overleaf/jpa-lazy-init-matcher

[web] initialize matcher for ignored file paths lazily

GitOrigin-RevId: ed04b286e188ad73e3090822965b19ccf2e7d2b4
Alf Eaton 2 лет назад
Родитель
Сommit
3cb4190ef0

+ 8 - 4
services/web/frontend/js/features/file-tree/util/is-acceptable-file.ts

@@ -1,11 +1,15 @@
 import { Minimatch } from 'minimatch'
 
-const fileIgnoreMatcher = new Minimatch(
-  window.ExposedSettings.fileIgnorePattern,
-  { nocase: true, dot: true }
-)
+let fileIgnoreMatcher: Minimatch
 
 export const isAcceptableFile = (name?: string, relativePath?: string) => {
+  if (!fileIgnoreMatcher) {
+    fileIgnoreMatcher = new Minimatch(
+      window.ExposedSettings.fileIgnorePattern,
+      { nocase: true, dot: true }
+    )
+  }
+
   if (!name) {
     // the file must have a name, of course
     return false