When to use SelectionRange in Selections

I was working on editing of hyperlinks and made a command that does a removeMark followed by an addMark. For positions of the Selection I use Selection.$from.pos and Selection.$to.pos.

However, in prosemirror-commands I see that the toggleMark function is using Selection.ranges for this. Although I have never seen Selection.ranges.length being more than 1. Is this ever possible for a TextSelection?

It is better to be on the safe side and always use Selection.ranges?

No, but for custom selections, like the cell selection in the tables plugin, it is. So if this is for a local setup and you know you won’t use such selections, it’s okay to just treat selection as a single range, but to be general, you might as well iterate over the ranges.

Tx. for the explanation! Now I also understand the idea behind multiple ranges.