phibr0 / obsidian-macros

Group multiple Commands into one Macro.
MIT License
19 stars 0 forks source link

Bug: Duplicate commands #2

Open zcysxy opened 3 years ago

zcysxy commented 3 years ago

Thanks for this nice plugin! It works perfectly when executing, but there are some bugs when creating macros. I think it may be caused by adding duplicate commands.

One bug is showed in the gif below, that is when adding one command, duplicate commands are inserted (notice that multiple decrease opacity commands in the gif are added manually one by one without any problem, and the buggy zoom in insertion was happened when editing the created macro)

macros bug

Another bug is that when adding a new macro (with the former one having duplicate commands), commands in the new macro are inserted into the former one, and are duplicated. Please see the following image

image

phibr0 commented 3 years ago

Could you send me the data.json file inside the plugins folder?

phibr0 commented 3 years ago

Until I get to fix the edit functionality I will just "remove it". It will be re-enabled once its fixed

zcysxy commented 3 years ago

I removed the redundant commands directly in the json file, and then everything works normally. And the result json file (without redundant commands) is this:

{
  "macros": [
    {
      "mobileOnly": false,
      "icon": "feather-minimize",
      "commandID": "macro-plugin:mini",
      "commands": [
        "obsidian-hider:toggle-app-ribbon",
        "obsidian-hider:toggle-hider-status",
        "obsidian-focus-mode:toggle-super-focus-mode",
        "sliding-panes-obsidian:toggle-sliding-panes",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-toggle-on-top",
        "obsidian-zoom:zoom-in"
      ],
      "delay": 10,
      "name": "mini"
    },
    {
      "mobileOnly": false,
      "icon": "feather-maximize",
      "commandID": "macro-plugin:maxi",
      "commands": [
        "obsidian-electron-window-tweaker:ewt-toggle-on-top",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-focus-mode:toggle-focus-mode",
        "obsidian-hider:toggle-hider-status",
        "obsidian-hider:toggle-app-ribbon",
        "sliding-panes-obsidian:toggle-sliding-panes",
        "obsidian-zoom:zoom-out"
      ],
      "delay": 10,
      "name": "maxi"
    }
  ]
}

And then I created two new test macros, the result json file is

{
  "macros": [
    {
      "mobileOnly": false,
      "icon": "feather-minimize",
      "commandID": "macro-plugin:mini",
      "commands": [
        "obsidian-hider:toggle-app-ribbon",
        "obsidian-hider:toggle-hider-status",
        "obsidian-focus-mode:toggle-super-focus-mode",
        "sliding-panes-obsidian:toggle-sliding-panes",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-toggle-on-top",
        "obsidian-zoom:zoom-in"
      ],
      "delay": 10,
      "name": "mini"
    },
    {
      "mobileOnly": false,
      "icon": "feather-maximize",
      "commandID": "macro-plugin:maxi",
      "commands": [
        "obsidian-electron-window-tweaker:ewt-toggle-on-top",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-focus-mode:toggle-focus-mode",
        "obsidian-hider:toggle-hider-status",
        "obsidian-hider:toggle-app-ribbon",
        "sliding-panes-obsidian:toggle-sliding-panes",
        "obsidian-zoom:zoom-out"
      ],
      "delay": 10,
      "name": "maxi"
    },
    {
      "mobileOnly": false,
      "icon": "bold-glyph",
      "commandID": "macro-plugin:test-1",
      "commands": [
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "obsidian-electron-window-tweaker:ewt-decrease-opacity",
        "workspace:copy-url",
        "workspace:copy-path"
      ],
      "delay": 10,
      "name": "test-1"
    },
    {
      "mobileOnly": false,
      "icon": "bracket-glyph",
      "commandID": "macro-plugin:test-2",
      "commands": [
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-electron-window-tweaker:ewt-increase-opacity",
        "obsidian-zoom:zoom-in",
        "workspace:copy-url",
        "workspace:copy-path",
        "workspace:copy-path",
        "workspace:copy-path"
      ],
      "delay": 10,
      "name": "test-2"
    }
  ]
}

You can see that I first put some duplicate commands (decrease opacity and increase opacity) in test-1 and test-2 (at that time no error occurred). But then when I added copy-url to test-1, the same command was wrongly inserted into test-2 (later created one). And then when I added copy-path to test-2, three duplicate commands were inserted, and at the same time one command was also inserted into test-1. 😵

phibr0 commented 3 years ago

Thats what I get for coding at 3 am. 🤣