Fix tab insertion when line is partly selected.

Fixed the behavior when a tab is inserted and text is marked. When a whole
single line is selected or multiple lines are selected, the line(s) are
indented. Otherwise, therefore one line is partly selected, then the
selected text is overwritten with a tab.

Fixes #877