diff --git a/src/main/globalSetting.js b/src/main/globalSetting.js index 1914328a..dd9fcf6f 100644 --- a/src/main/globalSetting.js +++ b/src/main/globalSetting.js @@ -1,11 +1,8 @@ -/** - * Set `__static` path to static files in production - * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html - */ - +// Set `__static` path to static files in production if (process.env.NODE_ENV !== 'development') { global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') } global.MARKTEXT_DEBUG = process.env.MARKTEXT_DEBUG || process.env.NODE_ENV !== 'production' +global.MARKTEXT_DEBUG_VERBOSE = global.MARKTEXT_DEBUG && process.env.MARKTEXT_DEBUG_VERBOSE global.MARKTEXT_SAFE_MODE = false diff --git a/src/main/watcher.js b/src/main/watcher.js index eb2550cf..6765ddd4 100644 --- a/src/main/watcher.js +++ b/src/main/watcher.js @@ -4,6 +4,7 @@ import { promisify } from 'util' import chokidar from 'chokidar' import { getUniqueId, log, hasMarkdownExtension } from './utils' import { loadMarkdownFile } from './utils/filesystem' +import { isLinux } from './config' const EVENT_NAME = { dir: 'AGANI::update-object-tree', @@ -102,8 +103,23 @@ class Watcher { .on('unlink', pathname => unlink(win, pathname, type)) .on('addDir', pathname => addDir(win, pathname)) .on('unlinkDir', pathname => unlinkDir(win, pathname)) + .on('raw', (event, path, details) => { + if (global.MARKTEXT_DEBUG_VERBOSE) { + console.log(event, path, details) + } + + // rename syscall on Linux (chokidar#591) + if (isLinux && event === 'rename') { + const { watchedPath } = details + // Use the same watcher and re-watch the file. + watcher.unwatch(watchedPath) + watcher.add(watchedPath) + } + }) .on('error', error => { - log(`Watcher error: ${error}`) + const msg = `Watcher error: ${error}` + console.log(msg) + log(msg) }) this.watchers[id] = { diff --git a/src/renderer/store/editor.js b/src/renderer/store/editor.js index a78062ce..1d29a806 100644 --- a/src/renderer/store/editor.js +++ b/src/renderer/store/editor.js @@ -635,6 +635,8 @@ const actions = { LISTEN_FOR_FILE_CHANGE ({ commit, state, rootState }) { ipcRenderer.on('AGANI::update-file', (e, { type, change }) => { + // TODO: Set `isSaved` to false. + // TODO: A new "changed" notification from different files overwrite the old notification - the old notification disappears. if (type === 'unlink') { return notice.notify({ title: 'File Removed on Disk',