I'm using NSControlTextEditingDelegate to auto complete what's
typed in a NSSearchField with custom suggestions I generate.
complete:
message is sent to field editor
when text is changed.
Now I'd like to fine-tune the behavior of auto-completion and have it working exactly as Google search text field works in Safari:
When two or more words (separated by spaces) are typed in NSTextField, location for NSRange passed in
control:textView:textView:completions:forPartialWordRange: indexOfSelectedItem:
starts after the last space typed.This means that if user types "San Fran" and Google APIs returns "San Francisco", choosing it from auto-complete list NSTextField value is replaced with "San San Francisco".
A possible workaround consist in rebuilding NSArray containing completion and returning only the suffix of the actual suggestions, depending on charRange.location. This looks crappy (because auto-completion list now shows only part of the completion string), so I want to have
NSTextField
ignore spaces when requesting auto-completion.Choosing an auto completion from list, default NSSearchField action is not sent. At the moment user need to choose an auto completion and then press enter to trigger search.