 
     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()

        updateLockIcon()
        updateUrlIcons()
        let _ = urlText.resignFirstResponder()
        delegate?.urlBarDidDismiss(self)
        setTextToURL()
        
        cancelButton.animateHidden(true, duration: UIConstants.layout.urlBarTransitionAnimationDuration)
        hideCancelConstraints.forEach { $0.activate() }
