How to handle templater scripts eating selection #419
scwunch
started this conversation in
Ideas & Feature Requests
Replies: 1 comment 1 reply
-
Hello @scwunch !!! My deepest thank you for sharing this Snippet. I was struggling with a workflow related to text selection for almost a year and your snippet save my Obsidian life. 💙💙💙 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was writing a templater script to modify text — but only selected text — in the active file. I noticed that, no matter what I did, it just eats up my selection and doesn't give it back. At first I was confused, but then I realized that Templater actually always eats my selection — no matter what function is called — and doesn't give it back. I could manually bring it back with a
tR += previouslySelectedText
oreditor.replaceSelection(previouslySelectedText)
or something like that, but then my cursor is back to caret mode rather than selection mode.I ended up "solving" this problem with this snippet of code:
I don't know why
setTimeout(... 0)
works, but it does. I'm curious also if there are other better workarounds.Beta Was this translation helpful? Give feedback.
All reactions