diff --git a/manifest.json b/manifest.json index d660f8b..1f4e0ca 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "pane-relief", "name": "Pane Relief", - "version": "0.2.4", + "version": "0.2.5", "minAppVersion": "0.14.5", "description": "Per-pane history, hotkeys for pane movement + navigation, and more", "author": "PJ Eby", diff --git a/src/focus-lock.ts b/src/focus-lock.ts index b030997..6120c48 100644 --- a/src/focus-lock.ts +++ b/src/focus-lock.ts @@ -1,6 +1,6 @@ import { around } from "monkey-around"; import { Notice, Plugin, setIcon, Workspace, WorkspaceLeaf } from "obsidian"; -import { LayoutSetting, Service } from "@ophidian/core"; +import { defer, LayoutSetting, Service } from "@ophidian/core"; import { addCommands, command } from "./commands"; import { setTooltip } from "./Navigator"; @@ -52,7 +52,34 @@ export class FocusLock extends Service { return old.call(this) && (!self.isLocked || isMain(this)); } } - })) + })); + this.register(around((app as any).internalPlugins.plugins["file-explorer"].instance, { + init(old) { return function init(...args: any[]) { + try { return old.apply(this, args); } finally { self.blockFileExplorerReveal(); } + }} + })); + this.blockFileExplorerReveal(); + } + + blockFileExplorerReveal() { + const self = this; + const raf = (app.commands as any).commands["file-explorer:reveal-active-file"]; + if (raf) this.register(around(raf, { + checkCallback(old) { + return function (...args: any[]) { + if (self.isLocked) for (const leaf of app.workspace.getLeavesOfType("file-explorer")) { + if (!isMain(leaf)) { + const el: HTMLElement = (leaf.view as any).dom?.navFileContainerEl; + el && defer(around(el, {focus(old) { + // Block focus stealing + return function() {}; + }})); + } + } + return old?.apply(this, args); + } + } + })); } toggle() { diff --git a/versions.json b/versions.json index 84a4248..c158c3d 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "0.2.4": "0.14.5", + "0.2.5": "0.14.5", "0.2.0": "0.14.5", "0.1.15": "0.14.5", "0.0.26": "0.14.5",