fix: cannot open leaf when last leaf is pinned

This commit is contained in:
quorafind 2024-01-24 17:18:54 +08:00
parent 32b64ea642
commit 5330b125f0

View file

@ -170,7 +170,8 @@ export default class FloatSearchPlugin extends Plugin {
if (activeLeaf.view.getViewType() === "markdown") {
return activeLeaf;
}
const newLeaf = self.app.workspace.getUnpinnedLeaf();
const newLeaf = self.app.workspace.getMostRecentLeaf();
if (newLeaf) {
this.setActiveLeaf(newLeaf);
}
@ -207,12 +208,21 @@ export default class FloatSearchPlugin extends Plugin {
if (parent === self.app.workspace.rootSplit || (WorkspaceContainer && parent instanceof WorkspaceContainer)) {
for (const popover of EmbeddedView.popoversForWindow((parent as WorkspaceContainer).win)) {
// Use old API here for compat w/0.14.x
if (old.call(this, cb, popover.rootSplit)) return true;
if (old.call(this, cb, popover.rootSplit)) return false;
}
}
return false;
};
},
setActiveLeaf(old) {
return function (leaf: any, params?: any) {
if (isEmebeddedLeaf(leaf)) {
old.call(this, leaf, params);
leaf.activeTime = 1700000000000;
}
return old.call(this, leaf, params);
};
},
onDragLeaf(old) {
return function (event: MouseEvent, leaf: WorkspaceLeaf) {
return old.call(this, event, leaf);
@ -308,7 +318,6 @@ export default class FloatSearchPlugin extends Plugin {
patchSearchView() {
const updateCurrentState = (state: searchState) => {
this.state = state;
console.log(state);
this.settings.searchViewState = state as searchState;
this.applySettingsUpdate();
};
@ -406,7 +415,6 @@ export default class FloatSearchPlugin extends Plugin {
})
);
searchView.leaf?.rebuildView();
console.log("Metadata-Style: all property view get patched");
return true;
};
this.app.workspace.onLayoutReady(() => {
@ -503,7 +511,6 @@ export default class FloatSearchPlugin extends Plugin {
case "split":
// @ts-ignore
const isExistingLeaf = existingLeaf.find((leaf) => !leaf.parentSplit.parent.side);
console.log(isExistingLeaf);
if (isExistingLeaf) {
this.app.workspace.revealLeaf(isExistingLeaf);
isExistingLeaf.setViewState({