Skip to content

Commit

Permalink
fix: don't refold creases when refocusing an open file
Browse files Browse the repository at this point in the history
liamcain committed Apr 4, 2022
1 parent 6040c00 commit ced7ab1
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"id": "creases",
"name": "Creases",
"description": "Tools for efficiently folding markdown sections in Obsidian",
"version": "0.6.0",
"version": "0.6.1",
"author": "Liam Cain",
"authorUrl": "https://github.com/liamcain/",
"isDesktopOnly": false,
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-creases",
"version": "0.6.0",
"version": "0.6.1",
"description": "Configurable folding within Obsidian",
"author": "liamcain",
"main": "main.js",
15 changes: 8 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -105,7 +105,6 @@ export default class CreasesPlugin extends Plugin {

this.app.workspace.onLayoutReady(() => {
this.registerEvent(this.app.vault.on("create", this.onNewFile.bind(this)));
this.registerEvent(this.app.workspace.on("file-open", this.onFileOpen.bind(this)));
this.patchMarkdownView();
this.patchCoreTemplatePlugin();
this.patchFileSuggest();
@@ -189,12 +188,6 @@ export default class CreasesPlugin extends Plugin {
}
}

private onFileOpen(file: TFile | null): void {
if (file && this.settings.onOpenCreasesBehavior === "always-fold") {
this.foldCreasesForFile(file);
}
}

private async onNewFile(fileOrFolder: TAbstractFile): Promise<void> {
if (!(fileOrFolder instanceof TFile)) {
return;
@@ -370,6 +363,14 @@ export default class CreasesPlugin extends Plugin {
}
};
},
onLoadFile(old: (file: TFile) => void) {
return async function (file: TFile) {
await old.call(this, file);
if (file && plugin.settings.onOpenCreasesBehavior === "always-fold") {
plugin.foldCreasesForFile(file);
}
};
},
})
);
}

1 comment on commit ced7ab1

@cansar
Copy link

@cansar cansar commented on ced7ab1 Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing. I just changed my settings to not fold by default (because this was getting in my way) seconds before this refreshing my plugins and seeing this change. Thanks for the fix!

Please sign in to comment.