diff --git a/src/renderer/components/FileTabs.vue b/src/renderer/components/FileTabs.vue index 7224b7c6..e0d5cf0a 100644 --- a/src/renderer/components/FileTabs.vue +++ b/src/renderer/components/FileTabs.vue @@ -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) } } diff --git a/src/renderer/plugins/document-history-stack.ts b/src/renderer/plugins/document-history-stack.ts index d2ea68d7..3ce9fc54 100644 --- a/src/renderer/plugins/document-history-stack.ts +++ b/src/renderer/plugins/document-history-stack.ts @@ -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),