diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index 865713259..4e467661a 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -215,6 +215,10 @@ export const openFile = (options: IOpenFileOptions) => { wnd.parent.children.find((item, index) => { if (item.id === wnd.id) { let nextWnd = wnd.parent.children[index + 1]; + if (!nextWnd) { + // wnd 为右侧时,应设置其为目标 + nextWnd = wnd; + } while (nextWnd instanceof Layout) { nextWnd = nextWnd.children[0]; } diff --git a/app/src/search/util.ts b/app/src/search/util.ts index 781859ebd..1ab533b68 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -104,7 +104,7 @@ export const openGlobalSearch = (app: App, text: string, replace: boolean) => { removed: localData.removed, page: 1 }, - position: "right" + position: (window.siyuan.layout.centerLayout.children.length > 1 || window.innerWidth > 1024) ? "right" : undefined }); }; @@ -492,7 +492,11 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo } else if (target.id === "searchOpen") { config.k = searchInputElement.value; config.r = replaceInputElement.value; - openFile({app, searchData: config, position: "right"}); + openFile({ + app, + searchData: config, + position: (window.siyuan.layout.centerLayout.children.length > 1 || window.innerWidth > 1024) ? "right" : undefined + }); if (closeCB) { closeCB(); }