diff --git a/src/common/filesystem/paths.js b/src/common/filesystem/paths.js
index 111b5a0b..c3a0d3f2 100644
--- a/src/common/filesystem/paths.js
+++ b/src/common/filesystem/paths.js
@@ -1,6 +1,7 @@
import fs from 'fs'
import path from 'path'
import { isFile, isFile2, isSymbolicLink } from './index'
+import minimatch from 'minimatch'
const isOsx = process.platform === 'darwin'
@@ -120,3 +121,19 @@ export const getResourcesPath = () => {
}
return resPath
}
+
+/**
+ * Returns true if the pathname matches one of the exclude patterns.
+ *
+ * @param {string} pathname Path of file or directory
+ * @param {string} patterns Glob expressions
+ */
+export const checkPathExcludePattern = (pathname, patterns) => {
+ if (!pathname || typeof pathname !== 'string') return false
+ for (const pattern of patterns) {
+ if (minimatch(pathname, pattern, { matchBase: true })) {
+ return true
+ }
+ }
+ return false
+}
diff --git a/src/main/filesystem/watcher.js b/src/main/filesystem/watcher.js
index b76ebe28..7789865a 100644
--- a/src/main/filesystem/watcher.js
+++ b/src/main/filesystem/watcher.js
@@ -3,7 +3,7 @@ import fsPromises from 'fs/promises'
import log from 'electron-log'
import chokidar from 'chokidar'
import { exists } from 'common/filesystem'
-import { hasMarkdownExtension } from 'common/filesystem/paths'
+import { hasMarkdownExtension, checkPathExcludePattern } from 'common/filesystem/paths'
import { getUniqueId } from '../utils'
import { loadMarkdownFile } from '../filesystem/markdown'
import { isLinux, isOsx } from '../config'
@@ -159,6 +159,10 @@ class Watcher {
if (/(?:^|[/\\])(?:\..|node_modules|(?:.+\.asar))/.test(pathname)) {
return true
}
+
+ if (checkPathExcludePattern(pathname, this._preferences.getItem('treePathExcludePatterns'))) {
+ return true
+ }
if (fileInfo.isDirectory()) {
return false
}
diff --git a/src/renderer/prefComponents/general/index.vue b/src/renderer/prefComponents/general/index.vue
index 501c3150..7dd1c479 100644
--- a/src/renderer/prefComponents/general/index.vue
+++ b/src/renderer/prefComponents/general/index.vue
@@ -71,6 +71,14 @@
:onChange="value => onSelectChange('wordWrapInToc', value)"
>
+
+
state.preferences.defaultDirectoryToOpen,
openFilesInNewWindow: state => state.preferences.openFilesInNewWindow,
openFolderInNewWindow: state => state.preferences.openFolderInNewWindow,
+ projectPaths: state => state.preferences.treePathExcludePatterns,
zoom: state => state.preferences.zoom,
hideScrollbar: state => state.preferences.hideScrollbar,
wordWrapInToc: state => state.preferences.wordWrapInToc,
diff --git a/src/renderer/store/preferences.js b/src/renderer/store/preferences.js
index 76a66009..ba28efeb 100644
--- a/src/renderer/store/preferences.js
+++ b/src/renderer/store/preferences.js
@@ -14,6 +14,7 @@ const state = {
fileSortBy: 'created',
startUpAction: 'lastState',
defaultDirectoryToOpen: '',
+ treePathExcludePatterns: [],
language: 'en',
editorFontFamily: 'Open Sans',
diff --git a/static/preference.json b/static/preference.json
index a3e60cc2..814a73e4 100644
--- a/static/preference.json
+++ b/static/preference.json
@@ -10,6 +10,7 @@
"fileSortBy": "created",
"startUpAction": "lastState",
"defaultDirectoryToOpen": "",
+ "treePathExcludePatterns": [],
"language": "en",
"editorFontFamily": "Open Sans",