From 91515242d4b0cff681b3e67fc26b0a859f56a09a Mon Sep 17 00:00:00 2001 From: Ran Luo Date: Mon, 30 Sep 2019 06:29:03 +0800 Subject: [PATCH] fix: #1249 (#1400) --- src/renderer/store/editor.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/renderer/store/editor.js b/src/renderer/store/editor.js index e2c83708..6505bdda 100644 --- a/src/renderer/store/editor.js +++ b/src/renderer/store/editor.js @@ -59,11 +59,12 @@ const mutations = { window.DIRNAME = pathname ? path.dirname(pathname) : '' bus.$emit('file-changed', { id, markdown, cursor, renderCursor: true, history }) } + } + + if (state.tabs.length === 0) { // Handle close the last tab, need to reset the TOC state - if (Object.keys(fileState).length === 0) { - state.listToc = [] - state.toc = [] - } + state.listToc = [] + state.toc = [] } }, // Exchange from with to and move from to the end if to is null or empty. @@ -252,6 +253,12 @@ const mutations = { bus.$emit('file-changed', { id, markdown, cursor, renderCursor: true, history }) } } + + if (state.tabs.length === 0) { + // Handle close the last tab, need to reset the TOC state + state.listToc = [] + state.toc = [] + } }, RENAME_IF_NEEDED (state, { src, dest }) { const { tabs } = state