From 5acdc1f3c7ba76883bb9bb2ecfc7dc9ff1ad444e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 10 Aug 2022 11:24:12 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=88=A0=E9=99=A4=E5=B7=B2=E6=89=93?= =?UTF-8?q?=E5=BC=80=E9=A1=B5=E7=AD=BE=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/dialog/processSystem.ts | 2 +- app/src/layout/Wnd.ts | 10 +++++----- app/src/protyle/index.ts | 4 ++-- app/src/protyle/util/onGet.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index 5edf4c700..35b8bce60 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -34,7 +34,7 @@ export const lockFile = (id: string) => { /// #if !MOBILE getAllModels().editor.find((item) => { if (item.editor.protyle.block.rootID === id) { - item.parent.parent.removeTab(item.parent.id); + item.parent.parent.removeTab(item.parent.id, false, false); return true; } }); diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index e9a1b7bf6..6524d2454 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -482,10 +482,10 @@ export class Wnd { model.send("closews", {}); } - private removeTabAction = (id: string, closeAll = false) => { + private removeTabAction = (id: string, closeAll = false, hasSaveScroll = true) => { this.children.find((item, index) => { if (item.id === id) { - if (item.model instanceof Editor) { + if (item.model instanceof Editor && hasSaveScroll) { saveScroll(item.model.editor.protyle); } if (this.children.length === 1) { @@ -545,7 +545,7 @@ export class Wnd { /// #endif }; - public removeTab(id: string, closeAll = false) { + public removeTab(id: string, closeAll = false, needSaveScroll = true) { for (let index = 0; index < this.children.length; index++) { const item = this.children[index]; if (item.id === id) { @@ -554,9 +554,9 @@ export class Wnd { showMessage(window.siyuan.languages.uploading); return; } - this.removeTabAction(id, closeAll); + this.removeTabAction(id, closeAll, needSaveScroll); } else { - this.removeTabAction(id, closeAll); + this.removeTabAction(id, closeAll, needSaveScroll); } return; } diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index 3df7113d6..6ca93f429 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -140,13 +140,13 @@ class Protyle { break; case "unmount": if (this.protyle.model && this.protyle.notebookId === data.data.box) { - this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id); + this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false); } break; case "remove": if (this.protyle.model && (this.protyle.notebookId === data.data.box && (!data.data.path || this.protyle.path.indexOf(getDisplayName(data.data.path, false, true)) === 0))) { - this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id); + this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false); } break; } diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index 23c00d592..b1846d985 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -21,7 +21,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[] if (data.code === 1) { // 其他报错 if (protyle.model) { - protyle.model.parent.parent.removeTab(protyle.model.parent.id); + protyle.model.parent.parent.removeTab(protyle.model.parent.id, false, false); } else { protyle.element.innerHTML = `
${window.siyuan.languages.refExpired}
`; }