extended duplicate line to also duplicate selected text

added functionality to duplicate selected text when applicable rather than duplicating the line the caret is on.
This time it's the right one, honest! (third time lucky)