-
Notifications
You must be signed in to change notification settings - Fork 30
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
Race Condition with Templater #55
Comments
Bug for 2. SilentVoid13/Templater#636 (comment) |
I just ran into this issue as well. Filename Heading Sync causes templater's await tp.file.rename(newFilename) to not work. Specifically, in my case, it renames the file but doesn't include the rest of the template commands. Or perhaps the other template commands work but then Filename Heading sync deletes the content. Any insight on how this might be fixed? |
I also encountered this issue but with the Using this template, the note is placed directly in a specific folder and renamed using the move function:
As a temporary "workaround", if you can call it that, you can place the move or rename function call inside a setTimeout :
A little bit clunky since the note doesn't remain open but it is created with all the content from the template |
Good idea! With that strategy, this was the best I could come up with:
Close, but I'm not sure it quite does the trick in my situation since it closes the note and then I need to go back to the note I grab the selection from and delete the selection and link to the note. But I might keep tinkering. |
Sorry I don't use Templater and not sure what I could add to fix this race condition besides artificial delays, like was suggested here with filename-heading-sync is just using the normal obsidian events to do it's thing. If you rely heavily on templater and the artificial delay isn't doing it for you, maybe deactivate both hooks and sync only manually. The last release included 2 commands for manual syncing Any PRs for this issue are very welcome! |
I didn't want to disable file save hook because it was the feature that made me use this plugin but I guess the two manual commands will do for now. However, if you don't need heading sync after the template has been parsed and the file created, you can trigger those 2 commands through templater, after renaming or moving has occured :
|
I think another option would be to be able to select a "one-way" sync. So have options to
I think the issue also comes because "best practice" for templater is to use [[filename]]as a header. Need to test if removing the [[]] would remove the issue. On the other side I have [[filename|This is my Test File]]also as header. Perhaps my use case just doesn't support the syncing. |
any news on this by any chance? :) |
Use File Open Hook is disabled.
There are two issue I notice with my templates.
I do rename the title of the note with the templater function: await tp.file.rename(newFilename)
after that, I include a template file with tp.file.include(otherTemplate) which adds the frontmatter
and then I include another template which includes the H1.
Related to your plugin:
If the plugin is enabled the file rename doesn't work
if the plugin is disabled the file rename does work.
Probably related to templater:
Templater doesn't pick up the correct note title after the rename in the included templates. Looking into this issue atm too.
A workaround for 1) could be to either wait a little (which you already suggested for the original bug) or perhaps to allow more options to configure what the plugin does. For example, only update the H1 if the file is renamed, or only update the filename if the H1 is renamed.
The text was updated successfully, but these errors were encountered: