Skip to content

Commit 4ce29ad

Browse files
committed
Misc. Fixes
- Improved unmaximize/slide behaviors w/newer Obsidians - Restored view header pane numbering for Obsidian 1.6+ (which removed the view header icon from the app HTML)
1 parent 0258c5e commit 4ce29ad

File tree

5 files changed

+24
-25
lines changed

5 files changed

+24
-25
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "pane-relief",
33
"name": "Pane Relief",
4-
"version": "0.5.4",
4+
"version": "0.5.5",
55
"minAppVersion": "1.5.8",
66
"description": "Per-tab history, hotkeys for pane/tab movement, navigation, sliding workspace, and more",
77
"author": "PJ Eby",

src/maximizing.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class Maximizer extends Service {
3333

3434
const self = this
3535
this.register(around(app.workspace, {
36-
setActiveLeaf(old) { return function setActiveLeaf(leaf, pushHistory, focus) {
36+
setActiveLeaf(old) { return function setActiveLeaf(leaf, ...args: any[]) {
3737
// We have to do this here so that MarkdownView can be focused in the new pane
3838
const parent = self.parentForLeaf(leaf), oldParent = self.parentForLeaf(app.workspace.activeLeaf);
3939
if (
@@ -46,17 +46,9 @@ export class Maximizer extends Service {
4646
app.commands.executeCommandById("obsidian-hover-editor:restore-active-popover");
4747
}
4848
if (isMain(leaf) && parent) self.refresh(parent, parent.hasClass("should-maximize") ? leaf.containerEl : null);
49-
return old.call(this, leaf, pushHistory, focus);
49+
return old.call(this, leaf, ...args);
5050
}}
5151
}));
52-
this.register(around(WorkspaceTabs.prototype, {
53-
onContainerScroll(old) {
54-
return function() {
55-
// Don't hide tabs while we're switching modes
56-
if (!self.changing && this.containerEl.isShown()) return old.call(this)
57-
}
58-
}
59-
}))
6052

6153
// Replace the right sidebar toggle that gets hidden during maximize
6254
app.workspace.onLayoutReady(() => {
@@ -106,18 +98,22 @@ export class Maximizer extends Service {
10698
return;
10799
}
108100
}
109-
if (parent) this.refresh(parent, toggleClass(parent, "should-maximize") ? leaf.containerEl : null);
101+
let hadMax = !toggleClass(parent, "should-maximize");
102+
if (parent) this.refresh(parent, hadMax ? null : leaf.containerEl, hadMax);
110103
}
111104

112105
lastMaximized(parent: Element) {
113106
return parent.find(".workspace-leaf.is-maximized") || app.workspace.getMostRecentLeaf().containerEl;
114107
}
115108

116109
fixSlidingPanes = debounce(() => {
117-
const parent = app.workspace.activeLeaf.parentSplit;
118-
if (requireApiVersion("0.16.2") && parent instanceof WorkspaceTabs && parent.isStacked) {
119-
parent.containerEl.win.requestAnimationFrame(() => {
110+
activeWindow.requestAnimationFrame(() => {
111+
const {activeLeaf} = app.workspace;
112+
if (!activeLeaf) return;
113+
const parent = activeLeaf.parentSplit;
114+
if (requireApiVersion("0.16.2") && parent instanceof WorkspaceTabs && parent.isStacked) {
120115
const remove = around(parent.tabsContainerEl, {
116+
// Kill .behavior flag so that the *whole* tab scrolls to position
121117
scrollTo(old) { return function(optionsOrX, y?: number) {
122118
if (typeof optionsOrX === "object") {
123119
delete optionsOrX.behavior;
@@ -127,20 +123,20 @@ export class Maximizer extends Service {
127123
}}
128124
});
129125
try { parent.scrollIntoView(parent.currentTab); } finally { remove(); this.changing = false; }
130-
});
131-
} else {
132-
app.workspace.requestActiveLeafEvents();
133-
this.changing = false;
134-
}
126+
} else {
127+
this.changing = false;
128+
}
129+
activeLeaf.containerEl.scrollIntoView();
130+
});
135131
}, 1, true);
136132

137133
refresh(
138134
parent: Element,
139135
leafEl: Element =
140-
parent.hasClass("should-maximize") ? this.lastMaximized(parent) : null
136+
parent.hasClass("should-maximize") ? this.lastMaximized(parent) : null,
137+
hadMax = parent.hasClass("has-maximized")
141138
) {
142139
this.changing = true;
143-
const hadMax = parent.hasClass("has-maximized");
144140
parent.findAllSelf(".workspace-split, .workspace-tabs").forEach(split => {
145141
if (split === parent || this.parentFor(split) === parent)
146142
toggleClass(split, "has-maximized", leafEl ? split.contains(leafEl): false);

src/sliding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class SlidingPanes extends PerWindowComponent {
4747
this.container.focus();
4848
}
4949
if (options.active) {
50-
(leaf.containerEl.matchParent(".workspace-tabs") ?? leaf.containerEl).scrollIntoView({behavior: "smooth"});
50+
(leaf.containerEl.matchParent(".workspace-tabs") ?? leaf.containerEl).scrollIntoView();
5151
}
5252
this.manager.options.defaultValue = options;
5353
}

src/styles.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,17 @@ body.obsidian-themepocalypse { --pr-pane-number-bottom: 0px; }
287287
body.pane-relief-pane-numbering {
288288
/* Number panes in their headers */
289289
.workspace-split .workspace-leaf .view-header-icon { min-width: fit-content; display: inherit; }
290-
.workspace-split .workspace-leaf .view-header-icon::before
290+
.workspace-split .workspace-leaf .view-header-icon::before,
291+
.workspace-split .workspace-leaf .view-header-left .view-header-nav-buttons::before
291292
{
292293
content: "";
293294
display: inline-flex;
294295
position: relative;
295296
min-inline-size: 1em;
296297
bottom: var(--pr-pane-number-bottom);
297298
}
298-
.workspace-split .workspace-leaf.has-pane-relief-label .view-header-icon::before
299+
.workspace-split .workspace-leaf.has-pane-relief-label .view-header-icon::before,
300+
.workspace-split .workspace-leaf.has-pane-relief-label .view-header-left .view-header-nav-buttons::before
299301
{
300302
counter-reset: pane-number var(--pane-relief-label);
301303
content: counter(pane-number);

versions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"0.5.5": "1.5.8",
23
"0.5.4": "1.5.8",
34
"0.5.3": "1.5.8",
45
"0.5.2": "1.3.5",

0 commit comments

Comments
 (0)