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

{{selection}}: Show an error message if nothing is selected. #303

Closed Taitava closed 1 year ago

Taitava commented 1 year ago

Discussed in https://github.com/Taitava/obsidian-shellcommands/discussions/299

Originally posted by **Taitava** December 7, 2022 I tried to search for a discussion for this, but did not find. I thought I had written about this earlier, but maybe I don't remember correctly. Currently, if `{{selection}}` is used while **nothing** is selected, this variable returns just an empty string. It might be ok for most situations, but I'd like to make `{{selection}}` able to utilize the default value system (started by #190 and will be improved by #298). If nothing is selected, user should be able to define their own selection value, e.g. `No selection`. This change will mean that the default behavior of `{{selection}}` will change. **By default, it will show an error message and prevent shell command execution, if nothing is selected.** The error message should mention that this is new behavior for the variable, and that the old behavior (return an empty string and continue executing) can be restored by defining a global default value for `{{selection}}` in settings.
Taitava commented 1 year ago

Done.