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

Unified Diff: third_party/WebKit/Source/devtools/front_end/text_editor/TextEditorAutocompleteController.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/text_editor/TextEditorAutocompleteController.js
diff --git a/third_party/WebKit/Source/devtools/front_end/text_editor/TextEditorAutocompleteController.js b/third_party/WebKit/Source/devtools/front_end/text_editor/TextEditorAutocompleteController.js
index 6e64dc641d48561612468a8a954e54e57b72c8e5..080f19026187604515529810444725c7929d97cb 100644
--- a/third_party/WebKit/Source/devtools/front_end/text_editor/TextEditorAutocompleteController.js
+++ b/third_party/WebKit/Source/devtools/front_end/text_editor/TextEditorAutocompleteController.js
@@ -261,11 +261,11 @@ WebInspector.TextEditorAutocompleteController = class {
* @param {string} hint
*/
_setHint(hint) {
- if (!this._isCursorAtEndOfLine()) {
+ var query = this._textEditor.text(this._queryRange);
+ if (!this._isCursorAtEndOfLine() || !hint.startsWith(query)) {
this._clearHint();
return;
}
- var query = this._textEditor.text(this._queryRange);
var suffix = hint.substring(query.length).split('\n')[0];
this._hintElement.textContent = suffix;
var cursor = this._codeMirror.getCursor('to');
@@ -286,6 +286,8 @@ WebInspector.TextEditorAutocompleteController = class {
}
_clearHint() {
+ if (!this._hintElement.textContent)
+ return;
this._lastHintText = '';
this._hintElement.textContent = '';
if (this._hintMarker)
@@ -367,9 +369,6 @@ WebInspector.TextEditorAutocompleteController = class {
* @override
*/
acceptSuggestion() {
- if (this._queryRange.endColumn - this._queryRange.startColumn === this._currentSuggestion.length)
- return;
-
var selections = this._codeMirror.listSelections().slice();
var queryLength = this._queryRange.endColumn - this._queryRange.startColumn;
for (var i = selections.length - 1; i >= 0; --i) {

Powered by Google App Engine
This is Rietveld 408576698