Hi, I want to create a shortcut to comment my code. If I select some text, the text must be wrapped in /* */
or <!- -->
according to the type of the tiddler, and if the selection is empty the whole line where the cursor is must be commented.
I can do the first part but when I tried to put a list widget to test if the saved text is empty or not, my code doesnt work : even though the selection is not empty, it default on the “empty” list widget.
Can someone help ?
Here’s my code :
<$action-sendmessage
$message="tm-edit-text-operation"
$param="save-selection"
tiddler=<<qualify "$:/temp/selection">>
/>
<!-- The selection is not empty -->
<$list filter="[<qualify '$:/temp/selection'>get[text]]">
<$action-sendmessage
$message="tm-edit-text-operation"
$param="wrap-selection"
prefix="<!-- "
suffix=" -->"
/>
</$list>
<!-- The selection is empty-->
<$list filter="[<qualify '$:/temp/selection'>get[text]else[]]">
<$action-sendmessage
$message="tm-edit-text-operation"
$param="wrap-lines"
prefix="<!-- "
suffix=" -->"
/>
</$list>
<$action-deletetiddler $tiddler=<<qualify "$:/temp/selection">> />
EDIT: Here’s the final result
$ _showInfo_shortcuts_comment(5).json (874 Bytes)