 
     override fileprivate func rightViewRect(forBounds bounds: CGRect) -> CGRect {
         return super.rightViewRect(forBounds: bounds).offsetBy(dx: -UIConstants.layout.urlBarWidthInset, dy: 0)
+    }
+    
+    func textFieldDidBeginEditing(_ textField: UITextField) {
+        guard let autocompleteTextField = textField as? AutocompleteTextField else { return }
+        autocompleteTextField.highlightAll()
     }
 }
 


extension URLBar: AutocompleteTextFieldDelegate {
    func autocompleteTextFieldShouldBeginEditing(_ autocompleteTextField: AutocompleteTextField) -> Bool {
        
        setTextToURL()

        autocompleteTextField.highlightAll()
        
        if !isEditing && inBrowsingMode {
            present()

            components?.password = nil
            fullUrl = components?.url?.absoluteString
            truncatedURL = components?.host
            urlText.text = displayFullUrl ? fullUrl : truncatedURL
            truncatedUrlText.text = truncatedURL
        }
    }
