Improve handling of cursor_start and cursor_end for completions.

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

Add a guard on start

Fix logic for end > cursor_pos

Another ws add

WS tweak

WS again