Fix line-wise put before on an empty buffer

- Avoid special case in common 'Put' with trailing line break
- Handle special case for put after in 'PutAfterCaretCore'
- Add related CommandUtil and CommonOperations unit tests

Closes #1304
Repair conditions under which StringData is adjusted
Merge branch 'fixes-put-empty'