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
This is a really edge case bug, probably does not appear much in practise.
Define a custom variable with a default value, e.g. default for version:
Use the custom variable in a Prompt and click Try the prompt without executing any shell command:
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.
If no t_shell_command is available here, should call this.getGlobalDefaultValueConfiguration() instead of letting ?. set default_value_configuration to undefined.
This is a really edge case bug, probably does not appear much in practise.
Define a custom variable with a default value, e.g.![kuva](https://user-images.githubusercontent.com/13002142/222494080-4cddde44-a30b-4a1f-b7b6-8713b6d92f12.png)
default for version
:Use the custom variable in a Prompt and click Try the prompt without executing any shell command:![kuva](https://user-images.githubusercontent.com/13002142/222494562-a4e20f1d-511c-43a7-a89c-ac71e0a64531.png)
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 callthis.getGlobalDefaultValueConfiguration()
instead of letting?.
setdefault_value_configuration
toundefined
.