@Override public boolean deleteLeftWord(){
  mInputConnection.beginBatchEdit();
  if (mInputConnection.getSelectedText(0) != null) {
    mInputConnection.commitText("",0);
  }
 else {
    CharSequence beforeCursor=mInputConnection.getTextBeforeCursor(MAX_DELETABLE_CONTEXT,0);
    if (beforeCursor != null) {
      int beforeCursorLength=beforeCursor.length();
      Matcher m=WHITESPACE_AND_TOKEN.matcher(beforeCursor);
      int lastIndex=0;
      while (m.find()) {
        lastIndex=beforeCursorLength == m.end() ? m.start() : m.end();
      }
      if (lastIndex > 0) {
        mInputConnection.deleteSurroundingText(beforeCursorLength - lastIndex,0);
      }
 else       if (beforeCursorLength < MAX_DELETABLE_CONTEXT) {
        mInputConnection.deleteSurroundingText(beforeCursorLength,0);
      }
    }
  }
  mInputConnection.endBatchEdit();
  return true;
}

@ Override public boolean deleteLeftWord ( ) { mInputConnection . beginBatchEdit ( ) ; if ( mInputConnection . getSelectedText ( 0 ) != null ) { mInputConnection . commitText ( "" , 0 ) ; } else { CharSequence beforeCursor = mInputConnection . getTextBeforeCursor ( MAX_DELETABLE_CONTEXT , 0 ) ; if ( beforeCursor != null ) { int beforeCursorLength = beforeCursor . length ( ) ; Matcher m = WHITESPACE_AND_TOKEN . matcher ( beforeCursor ) ; int lastIndex = 0 ; while ( m . find ( ) ) { lastIndex = beforeCursorLength == m . end ( ) ? m . start ( ) : m . end ( ) ; } if ( lastIndex > 0 ) { mInputConnection . deleteSurroundingText ( beforeCursorLength - lastIndex , 0 ) ; } else if ( beforeCursorLength < MAX_DELETABLE_CONTEXT ) { mInputConnection . deleteSurroundingText ( beforeCursorLength , 0 ) ; } } } mInputConnection . endBatchEdit ( ) ; return true ; }
deletes all characters up to the leftmost whitespace from the cursor ( including the whitespace ) . if something is selected then delete the selection . todo : maybe expensive ?
