mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 02:10:29 +08:00
Check for same file before pasting (#3034)
This commit is contained in:
parent
fed1dac48f
commit
34e4a22857
@ -142,7 +142,7 @@ const actions = {
|
||||
const { pathname } = state.activeItem
|
||||
shell.trashItem(pathname).catch(err => {
|
||||
notice.notify({
|
||||
title: 'Deletion Error',
|
||||
title: 'Error while deleting',
|
||||
type: 'error',
|
||||
message: err.message
|
||||
})
|
||||
@ -156,15 +156,25 @@ const actions = {
|
||||
const { clipboard } = state
|
||||
const { pathname, isDirectory } = state.activeItem
|
||||
const dirname = isDirectory ? pathname : path.dirname(pathname)
|
||||
if (clipboard) {
|
||||
if (clipboard && clipboard.src) {
|
||||
clipboard.dest = dirname + PATH_SEPARATOR + path.basename(clipboard.src)
|
||||
|
||||
if (path.normalize(clipboard.src) === path.normalize(clipboard.dest)) {
|
||||
notice.notify({
|
||||
title: 'Paste Forbidden',
|
||||
type: 'warning',
|
||||
message: 'Source and destination must not be the same.'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
paste(clipboard)
|
||||
.then(() => {
|
||||
commit('SET_CLIPBOARD', null)
|
||||
})
|
||||
.catch(err => {
|
||||
notice.notify({
|
||||
title: 'Paste Error',
|
||||
title: 'Error while pasting',
|
||||
type: 'error',
|
||||
message: err.message
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user