Skip to content

Commit

Permalink
do not close tab if user aborted save action, fixed #38
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Aug 18, 2016
1 parent a4ae125 commit d149ba3
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/components/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,16 @@
const tab = this.tabs[index]
if (tab.filePath) {
await this.save({index, filePath: tab.filePath})
} else {
const filePath = remote.dialog.showSaveDialog(currentWindow, {
filters: [
{name: 'Markdown', extensions: ['markdown', 'md']}
]
})
if (filePath) await this.save({index, filePath})
return true
}
const filePath = remote.dialog.showSaveDialog(currentWindow, {
filters: [
{name: 'Markdown', extensions: ['markdown', 'md']}
]
})
if (filePath) {
await this.save({index, filePath})
return true
}
} catch (err) {
handleError(err)
Expand Down Expand Up @@ -461,9 +464,11 @@
buttons: ['Save', 'Cancel', 'Don\'t Save']
})
if (clickedButton === 0) {
await this.handleSave(index)
this.$store.dispatch('CLOSE_TAB', index)
return true
const saved = await this.handleSave(index)
if (saved) {
this.$store.dispatch('CLOSE_TAB', index)
return true
}
} else if (clickedButton === 2) {
this.$store.dispatch('UPDATE_SAVE_STATUS', {index, saved: true})
this.$store.dispatch('CLOSE_TAB', index)
Expand Down

0 comments on commit d149ba3

Please sign in to comment.