Skip to content

Commit d149ba3

Browse files
committed
do not close tab if user aborted save action, fixed #38
1 parent a4ae125 commit d149ba3

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/components/main.vue

+15-10
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,16 @@
156156
const tab = this.tabs[index]
157157
if (tab.filePath) {
158158
await this.save({index, filePath: tab.filePath})
159-
} else {
160-
const filePath = remote.dialog.showSaveDialog(currentWindow, {
161-
filters: [
162-
{name: 'Markdown', extensions: ['markdown', 'md']}
163-
]
164-
})
165-
if (filePath) await this.save({index, filePath})
159+
return true
160+
}
161+
const filePath = remote.dialog.showSaveDialog(currentWindow, {
162+
filters: [
163+
{name: 'Markdown', extensions: ['markdown', 'md']}
164+
]
165+
})
166+
if (filePath) {
167+
await this.save({index, filePath})
168+
return true
166169
}
167170
} catch (err) {
168171
handleError(err)
@@ -461,9 +464,11 @@
461464
buttons: ['Save', 'Cancel', 'Don\'t Save']
462465
})
463466
if (clickedButton === 0) {
464-
await this.handleSave(index)
465-
this.$store.dispatch('CLOSE_TAB', index)
466-
return true
467+
const saved = await this.handleSave(index)
468+
if (saved) {
469+
this.$store.dispatch('CLOSE_TAB', index)
470+
return true
471+
}
467472
} else if (clickedButton === 2) {
468473
this.$store.dispatch('UPDATE_SAVE_STATUS', {index, saved: true})
469474
this.$store.dispatch('CLOSE_TAB', index)

0 commit comments

Comments
 (0)