Improve handling of cursor_start and cursor_end for completions.

Improve handling of cursor_start and cursor_end for completions.

Fix handling of end != cursor_position
Fix handling of cursor offset and handle end <= start.

Fix handling of cursor offset and handle end <= start.

Reinstate extra whitespace

More whitespace reinstating

Still more whitespace

Finalwhitespace