Skip to content

Commit

Permalink
Fix 1.7.5 not opening search w/hotkey + focus lock
Browse files Browse the repository at this point in the history
Older versions of Obsidian focused the search box directly from
the search command, which allowed hotkey-based search to work
with Pane Relief's Focus Lock active.  Newer versions now do
the focusing in a way that is subject to Focus Lock, so this
release adds a workaround to emulate the old behavior.

Note: with the exception of taking focus away from popout windows,
Obsidian has fixed most of the problems in its UI that Focus Lock was
intended to prevent, so you may want to try turning off Focus Lock to
see if you still need it.  (The one other major use case for it is
keeping the "Automatically reveal active file" plugin from constantly
focusing the file explorer pane.)
  • Loading branch information
pjeby committed Nov 9, 2024
1 parent 4ce29ad commit 313ef66
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "pane-relief",
"name": "Pane Relief",
"version": "0.5.5",
"version": "0.5.6",
"minAppVersion": "1.5.8",
"description": "Per-tab history, hotkeys for pane/tab movement, navigation, sliding workspace, and more",
"author": "PJ Eby",
Expand Down
2 changes: 2 additions & 0 deletions src/focus-lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class FocusLock extends Service {
// Handle the case where there was no prior active leaf
if (!this.activeLeaf || !isLeafAttached(this.activeLeaf))
return old.call(this, this.getLeaf(), ...etc);
// Obsidian 1.7.x handles search focusing differently; this restores the old behavior
if (leaf.view?.getViewType() === "search" && etc[0] === true || etc[0]?.focus) leaf.setEphemeralState({focus: true});
}},
revealLeaf(old) {
return function(leaf: WorkspaceLeaf) {
Expand Down
3 changes: 1 addition & 2 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"0.5.6": "1.5.8",
"0.5.5": "1.5.8",
"0.5.4": "1.5.8",
"0.5.3": "1.5.8",
"0.5.2": "1.3.5",
"0.5.1": "1.2.8",
"0.4.2": "0.15.9",
Expand Down

0 comments on commit 313ef66

Please sign in to comment.