mProjectsCode / obsidian-meta-bind-plugin

A plugin for Obsidian to make your notes interactive with inline input fields, metadata displays, and buttons.
https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/
GNU General Public License v3.0
468 stars 38 forks source link

Replace Self not working after templater conversion #404

Open SandmansDreams opened 4 weeks ago

SandmansDreams commented 4 weeks ago

Please fill out these Check-boxes

Plugin Version

1.1.3

This Issue Occurs on

Debug Info

SYSTEM INFO:
    Obsidian version: v1.6.7
    Installer version: v1.4.16
    Operating system: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 23.6.0
    Login status: logged in
    Catalyst license: none
    Insider build toggle: off
    Live preview: on
    Base theme: dark
    Community theme: Spectrum Blue v1.0.0
    Snippets enabled: 4
    Restricted mode: off
    Plugins installed: 43
    Plugins enabled: 2
        1: Meta Bind v1.1.3
        2: Templater v2.4.1

RECOMMENDATIONS:
    Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Describe the Issue

When using a multi-action button and having the replaceself function, it only works (gets rid of the button) if the command function is run after the replaceself function. In this case it is a command for templater to replace the active templates in the file. Seems to work fine with other commands including other templater commands.

Steps to Reproduce

Run this button:

label: Templater Converter
icon: replace
hidden: false
class: ""
tooltip: Converts the template into a usable file.
id: TemplateConvert
style: destructive
actions:
  - type: replaceInNote
    fromLine: 3
    toLine: 3
    replacement: "tags:: #"
  - type: replaceInNote
    fromLine: 4
    toLine: 4
    replacement: "parent:: "
  - type: command
    command: templater-obsidian:replace-in-file-templater
  - type: replaceSelf
    replacement: ""

This button works (flipped the locations of the replaceself and templater converter):

label: Templater Converter
icon: replace
hidden: false
class: ""
tooltip: Converts the template into a usable file.
id: TemplateConvert
style: destructive
actions:
  - type: replaceInNote
    fromLine: 3
    toLine: 3
    replacement: "tags:: #"
  - type: replaceInNote
    fromLine: 4
    toLine: 4
    replacement: "parent:: "
  - type: replaceSelf
    replacement: ""
  - type: command
    command: templater-obsidian:replace-in-file-templater

Expected Behavior

The second button functions as expected. The first button does everything except the replaceself command.

mProjectsCode commented 3 weeks ago

I haven't looked at this closely, but my first guess is that Obsidians metadata cache (where I am pulling the line positions from) has not updated yet, so the line positions are wrong.

SandmansDreams commented 3 weeks ago

I haven't looked at this closely, but my first guess is that Obsidians metadata cache (where I am pulling the line positions from) has not updated yet, so the line positions are wrong.

Hmm that could make sense. It does not appear to remove any other lines, just seems to not happen. But could still be the case.

mProjectsCode commented 3 weeks ago

Does any error appear in the console?

SandmansDreams commented 3 weeks ago

Does any error appear in the console?

As far as I can tell, no. There were several errors before I cleared it and then ran the button. However, none of these errors seem to pertain to the button.

image