Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(906)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js

Issue 2478563002: DevTools: Substring autocomplete in Console and StylesSideBar. (Closed)
Patch Set: tests Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
index 0d7ac04e4de2ccd9afa93c0b8f7ba120c15b5f51..6ff3ce32f9abc03ded82e387b325d81c7b48d54f 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
@@ -278,12 +278,13 @@ WebInspector.SuggestBox = class {
_createItemElement(query, text, className) {
var element = createElementWithClass('div', 'suggest-box-content-item source-code ' + (className || ''));
element.tabIndex = -1;
- if (query && query.length && !text.indexOf(query)) {
- element.createChild('span', 'query').textContent = query;
- element.createChild('span').textContent = text.substring(query.length).trimEnd(50);
- } else {
- element.createChild('span').textContent = text.trimEnd(50);
- }
+ var displayText = text.trimEnd(50 + query.length);
+ var index = displayText.toLowerCase().indexOf(query.toLowerCase());
+ if (index > 0)
+ element.createChild('span').textContent = displayText.substring(0, index);
+ if (index > -1)
+ element.createChild('span', 'query').textContent = displayText.substring(index, index + query.length);
+ element.createChild('span').textContent = displayText.substring(index > -1 ? index + query.length : 0);
element.__fullValue = text;
element.createChild('span', 'spacer');
element.addEventListener('mousedown', this._onItemMouseDown.bind(this), false);
@@ -374,6 +375,9 @@ WebInspector.SuggestBox = class {
if (completions.length > 1)
return true;
+ if (!completions[0].title.startsWith(userEnteredText))
+ return true;
+
// Do not show a single suggestion if it is the same as user-entered query, even if allowed to show single-item suggest boxes.
return canShowForSingleItem && completions[0].title !== userEnteredText;
}

Powered by Google App Engine
This is Rietveld 408576698