mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
refactor: fix history-stack plugin switching issue
This commit is contained in:
@@ -29,15 +29,18 @@ export default {
|
||||
|
||||
const nextState = stack[index]
|
||||
|
||||
ctx.doc.switchDoc(nextState.doc, { source: 'history-stack', position: nextState.position })
|
||||
|
||||
idx = index
|
||||
refresh()
|
||||
ctx.doc.switchDoc(nextState.doc, { source: 'history-stack', position: nextState.position }).then(() => {
|
||||
idx = index
|
||||
refresh()
|
||||
})
|
||||
}
|
||||
|
||||
function removeFromStack (doc?: PathItem) {
|
||||
stack = stack.filter(x => !ctx.doc.isSubOrSameFile(doc, x.doc))
|
||||
idx = stack.length - 1
|
||||
if (idx >= stack.length) {
|
||||
idx = stack.length - 1
|
||||
}
|
||||
|
||||
refresh()
|
||||
}
|
||||
|
||||
@@ -117,6 +120,7 @@ export default {
|
||||
|
||||
ctx.registerHook('DOC_DELETED', ({ doc }) => removeFromStack(doc))
|
||||
ctx.registerHook('DOC_MOVED', ({ oldDoc }) => removeFromStack(oldDoc))
|
||||
ctx.registerHook('DOC_SWITCH_FAILED', ({ doc }) => { doc && removeFromStack(doc) })
|
||||
|
||||
ctx.action.registerAction({
|
||||
name: backId,
|
||||
|
||||
Reference in New Issue
Block a user