Index: components/autofill/content/renderer/autofill_agent.cc |
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc |
index 527e1810b8723d1617aa63abb1f5fa009458e6e4..915bdc90ac3f5bb8f7bed1fca4cecd56c2c13444 100644 |
--- a/components/autofill/content/renderer/autofill_agent.cc |
+++ b/components/autofill/content/renderer/autofill_agent.cc |
@@ -19,6 +19,7 @@ |
#include "components/autofill/core/common/autofill_constants.h" |
#include "components/autofill/core/common/autofill_data_validation.h" |
#include "components/autofill/core/common/autofill_switches.h" |
+#include "components/autofill/core/common/autofill_util.h" |
#include "components/autofill/core/common/form_data.h" |
#include "components/autofill/core/common/form_data_predictions.h" |
#include "components/autofill/core/common/form_field_data.h" |
@@ -765,8 +766,17 @@ void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
was_query_node_autofilled_ = element_.isAutofilled(); |
node->setSuggestedValue(value.substr(0, node->maxLength())); |
node->setAutofilled(true); |
- node->setSelectionRange(node->value().length(), |
- node->suggestedValue().length()); |
+ |
+ if (IsFeatureSubStringMatchEnabled()) { |
+ size_t start = 0, end = 0; |
+ if (base::string16::npos != |
+ ComputeRange(value, node->value(), &start, &end)) { |
+ node->setSelectionRange(start, end); |
+ } |
+ } else { |
+ node->setSelectionRange(node->value().length(), |
+ node->suggestedValue().length()); |
+ } |
} |
void AutofillAgent::ProcessForms() { |