code: public static SelectionRange findRegionFromSelection( String fullText, int selectionOffset, int selectionLength ) {
  
  		// Find the whole lines that match the selection (start)
  		int newSselectionOffset = TextUtils.fixSelectionOffset( fullText, selectionOffset );
  
  		// Modifying the offset can make the length slide => update it
  		selectionLength += selectionOffset - newSselectionOffset;
  		selectionOffset = newSselectionOffset;
  
  		// Find the whole lines that match the selection (end)
  		selectionLength = TextUtils.fixSelectionLength( fullText, selectionOffset, selectionLength );
  
  		return new SelectionRange( selectionOffset, selectionLength );
  	}
docs: Finds the region that includes both the given selection and entire lines.
  <p>
  Invalid values for the selection settings are fixed by this method.
  </p>
  
  @param fullText the full text
  @param selectionOffset the selection's offset
  @param selectionLength the selection's length
  @return a non-null selection range