mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
upd: 优化文件变动处理
This commit is contained in:
@@ -96,9 +96,10 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function handleMoved (payload?: { oldDoc: Doc }) {
|
||||
function handleMoved (payload?: { oldDoc: Doc, newDoc: Doc }) {
|
||||
if (payload) {
|
||||
removeFile(payload.oldDoc)
|
||||
switchFile(payload.newDoc)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,13 @@ export default {
|
||||
})
|
||||
}
|
||||
|
||||
function removeFromStack (doc?: Doc) {
|
||||
const newStack = stack.filter(x => ctx.doc.toUri(doc) !== ctx.doc.toUri(x))
|
||||
stack.splice(0, stack.length)
|
||||
stack.push(...newStack)
|
||||
updateMenu()
|
||||
}
|
||||
|
||||
ctx.bus.on('doc.switched', (file?: Doc) => {
|
||||
if (file) {
|
||||
if (!ctx.doc.isSameFile(stack[idx], file)) {
|
||||
@@ -62,6 +69,9 @@ export default {
|
||||
updateMenu()
|
||||
})
|
||||
|
||||
ctx.bus.on('doc.deleted', removeFromStack)
|
||||
ctx.bus.on('doc.moved', ({ oldDoc }) => removeFromStack(oldDoc))
|
||||
|
||||
ctx.action.registerAction({
|
||||
name: backId,
|
||||
handler: () => go(-1),
|
||||
|
||||
Reference in New Issue
Block a user