Repository: marktext/marktext
File: src/main/actions/file.js (JavaScript)

Code before:
  const win = BrowserWindow.fromWebContents(e.sender)
  if (pathname) {
    writeFileToFilesystem(pathname, markdown, e, err => {
      if (!err && quitAfterSave) forceClose(win)
    })
  } else {
    const filePath = dialog.showSaveDialog(win, {
      defaultPath: getPath('documents') + '/Untitled.md'
    })
    writeFile(filePath, markdown, '.md', win, e, quitAfterSave)
  }
}

ipcMain.on('AGANI::response-file-save-as', (e, { markdown, pathname }) => {
  const win = BrowserWindow.fromWebContents(e.sender)
  let filePath = dialog.showSaveDialog(win, {
    defaultPath: pathname || getPath('documents') + '/Untitled.md'
  })
  writeFile(filePath, markdown, '.md', win, e)
})

ipcMain.on('AGANI::response-close-confirm', (e, { filename, pathname, markdown }) => {
  const win = BrowserWindow.fromWebContents(e.sender)
  dialog.showMessageBox(win, {
    type: 'warning',
    buttons: ['Save', 'Cancel', 'Exit and don\'t save'],
    defaultId: 0,
    message: `Do you want to save the changes you made to ${filename}?`,
    detail: `Your changes will be lost if you don't save them.`,
    cancelId: 1,
    noLink: true
  }, index => {
    switch (index) {
      case 2:
        forceClose(win)
        break
      case 0:
        setTimeout(() => {
          handleResponseForSave(e, { pathname, markdown, quitAfterSave: true })
        })
        break
    }
  })
})

ipcMain.on('AGANI::response-file-save', handleResponseForSave)

ipcMain.on('AGANI::response-export', handleResponseForExport)

ipcMain.on('AGANI::close-window', e => {
  const win = BrowserWindow.fromWebContents(e.sender)

Review comment (suggestion):
I think `Delete` is the meaning of `Exit and don\'t save`, and many application use it, So I think user knew the exact meaning of `Delete`.

Code after:
  } else {
    const filePath = dialog.showSaveDialog(win, {
      defaultPath: getPath('documents') + '/Untitled.md'
    })
    writeMarkdownFile(filePath, markdown, '.md', win, e, quitAfterSave)
  }
}

ipcMain.on('AGANI::response-file-save-as', (e, { markdown, pathname }) => {
  const win = BrowserWindow.fromWebContents(e.sender)
  let filePath = dialog.showSaveDialog(win, {
    defaultPath: pathname || getPath('documents') + '/Untitled.md'
  })
  writeMarkdownFile(filePath, markdown, '.md', win, e)
})

ipcMain.on('AGANI::response-close-confirm', (e, { filename, pathname, markdown }) => {
  const win = BrowserWindow.fromWebContents(e.sender)
  dialog.showMessageBox(win, {
    type: 'warning',
    buttons: ['Save', 'Cancel', 'Delete'],
    defaultId: 0,
    message: `Do you want to save the changes you made to ${filename}?`,
    detail: `Your changes will be lost if you don't save them.`,
    cancelId: 1,
    noLink: true
  }, index => {
    switch (index) {
      case 2:
        forceClose(win)
        break
      case 0:
        setTimeout(() => {
          handleResponseForSave(e, { pathname, markdown, quitAfterSave: true })
        })
        break
    }
  })
})

ipcMain.on('AGANI::response-file-save', handleResponseForSave)

ipcMain.on('AGANI::response-export', handleResponseForExport)

ipcMain.on('AGANI::close-window', e => {
  const win = BrowserWindow.fromWebContents(e.sender)
  forceClose(win)
})

ipcMain.on('AGANI::window::drop', (e, fileList) => {
  for (const file of fileList) {