Taitava / obsidian-shellcommands

Execute system commands via hotkeys or command palette in Obsidian (https://obsidian.md). Some automated events are also supported, and execution via URI links.
GNU General Public License v3.0
336 stars 11 forks source link

Global default values for variables not working when previewing a Prompt #327

Closed Taitava closed 1 year ago

Taitava commented 1 year ago

This is a really edge case bug, probably does not appear much in practise.

  1. Define a custom variable with a default value, e.g. default for version: kuva

  2. Use the custom variable in a Prompt and click Try the prompt without executing any shell command: kuva

  3. Text _{{_scversion}}: This custom variable does not have a value yet, and no default value is defined. should not appear, it should show default for version instead.

The bug happens, because variable default value fetching only happens, if a shell command is available, but in a context where a Prompt is being tested, no shell command is used, so the default value fetching finds nothing.

https://github.com/Taitava/obsidian-shellcommands/blob/3f594646e30be98e01662202419fa1f0ff7d0128/src/variables/Variable.ts#L90

If no t_shell_command is available here, should call this.getGlobalDefaultValueConfiguration() instead of letting ?. set default_value_configuration to undefined.

Taitava commented 1 year ago

Fixed.