What you describe is already the behavior of the [[selection]]
tag. From the template docs:
[[selection]]
If text was selected within the draft before selecting an action, this tag will return only that selected text. If no text was selected, it will return the full text of the draft.
There is a separate [[selection_only]]
tag that does not revert to the full draft if there is no selection.