Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: app.workspace.getLeaf().openFile() replaces content in a note if called without "await" #1384

Open
erazlogo opened this issue May 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@erazlogo
Copy link

erazlogo commented May 25, 2024

Plugin information (please complete the following information):

  • OS: MacOS Sonoma 14.5
  • Templater version: 2.3.2
  • Obsidian version: 1.6.1
  • Templater settings: [Templater folder location: "meta/templater"]

Describe the bug
Since the last update, this script replaces the content in the note "advanced research notes search.md" with whatever note is open at the time I trigger the script via command palette:

<%*
const file = app.vault.getAbstractFileByPath('meta/dataview/advanced research notes search.md');
app.workspace.getLeaf(false).openFile(file); 
app.commands.executeCommandById('obsidian-focus-mode:toggle-super-focus-mode');
-%>

This script--"await" added before app.workspace.getLeaf--works as intended, opening "advanced research notes search.md" in a super focus mode:

<%*
const file = app.vault.getAbstractFileByPath('meta/dataview/advanced research notes search.md');
await app.workspace.getLeaf(false).openFile(file); 
app.commands.executeCommandById('obsidian-focus-mode:toggle-super-focus-mode');
-%>

It seems that even if the "await" is required before app.workspace.getLeaf, replacing content is not what should happen here. It could be that the other plugin is to blame but it's odd that it works in Templater with "await" but not without.

Expected behavior
Previously, the script without "await" worked to open "advanced research notes search.md" in a super focus mode.

@erazlogo erazlogo added the bug Something isn't working label May 25, 2024
@erazlogo erazlogo changed the title bug: a script replaces content in a note if a step is called without "await" bug: app.workspace.getLeaf(false).openFile() replaces content in a note if a step is called without "await" May 25, 2024
@erazlogo erazlogo changed the title bug: app.workspace.getLeaf(false).openFile() replaces content in a note if a step is called without "await" bug: app.workspace.getLeaf(false).openFile() replaces content in a note if called without "await" May 25, 2024
@erazlogo erazlogo changed the title bug: app.workspace.getLeaf(false).openFile() replaces content in a note if called without "await" bug: app.workspace.getLeaf().openFile() replaces content in a note if called without "await" May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant