title: Fine-tuning NSTextField auto completion
body: <p>I'm using NSControlTextEditingDelegate to auto complete what's
  typed in a NSSearchField with custom suggestions I generate.
  <code>complete:</code> message is sent to field editor
  when text is changed.</p>
  
  <p>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:</p>
  
  <ol>
  <li><p>When two or more words (separated by spaces) are typed in NSTextField,
  location for NSRange passed in <code>control:textView:textView:completions:forPartialWordRange:
  indexOfSelectedItem:</code> starts after the last space typed.</p>
  
  <p>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".</p>
  
  <p>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
  <code>NSTextField</code> ignore spaces when requesting auto-completion.</p></li>
  <li><p>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.</p></li>
  </ol>