Changeset 107402 in webkit
- Timestamp:
- Feb 10, 2012 7:41:41 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107399 r107402 1 2012-02-10 Alexander Pavlov <apavlov@chromium.org> 2 3 Web Inspector: [TextPrompt] TAB should complete suggestions up to their common prefix in Console 4 https://bugs.webkit.org/show_bug.cgi?id=78236 5 6 Reviewed by Vsevolod Vlasov. 7 8 * inspector/front-end/TextPrompt.js: 9 (WebInspector.TextPrompt.prototype._completionsReady): 10 (WebInspector.TextPrompt.prototype._completeCommonPrefix): 11 (WebInspector.TextPrompt.prototype.acceptSuggestion): 12 (WebInspector.TextPrompt.prototype.tabKeyPressed): 13 1 14 2012-02-10 Pavel Feldman <pfeldman@google.com> 2 15 -
trunk/Source/WebCore/inspector/front-end/TextPrompt.js
r105628 r107402 401 401 402 402 /** 403 * @param {Array.<string>} completions 404 * @param {number} wordPrefixLength 405 */ 406 _buildCommonPrefix: function(completions, wordPrefixLength) 407 { 408 var commonPrefix = completions[0]; 409 for (var i = 0; i < completions.length; ++i) { 410 var completion = completions[i]; 411 var lastIndex = Math.min(commonPrefix.length, completion.length); 412 for (var j = wordPrefixLength; j < lastIndex; ++j) { 413 if (commonPrefix[j] !== completion[j]) { 414 commonPrefix = commonPrefix.substr(0, j); 415 break; 416 } 417 } 418 } 419 return commonPrefix; 420 }, 421 422 /** 403 423 * @param {Selection} selection 404 424 * @param {boolean} auto … … 431 451 var wordPrefixLength = originalWordPrefixRange.toString().length; 432 452 433 if (auto) 453 if (auto) { 434 454 var completionText = completions[0]; 435 else { 455 var commonPrefix = this._buildCommonPrefix(completions, wordPrefixLength); 456 457 this._commonPrefix = commonPrefix; 458 } else { 436 459 if (completions.length === 1) { 437 460 var completionText = completions[0]; 438 461 wordPrefixLength = completionText.length; 439 462 } else { 440 var commonPrefix = completions[0]; 441 for (var i = 0; i < completions.length; ++i) { 442 var completion = completions[i]; 443 var lastIndex = Math.min(commonPrefix.length, completion.length); 444 for (var j = wordPrefixLength; j < lastIndex; ++j) { 445 if (commonPrefix[j] !== completion[j]) { 446 commonPrefix = commonPrefix.substr(0, j); 447 break; 448 } 449 } 450 } 463 var commonPrefix = this._buildCommonPrefix(completions, wordPrefixLength); 451 464 wordPrefixLength = commonPrefix.length; 452 465 … … 499 512 }, 500 513 514 _completeCommonPrefix: function() 515 { 516 if (!this.autoCompleteElement || !this._commonPrefix || !this._userEnteredText || this._commonPrefix.indexOf(this._userEnteredText) !== 0) 517 return; 518 519 if (!this.isSuggestBoxVisible()) { 520 this.acceptAutoComplete(); 521 return; 522 } 523 524 this.autoCompleteElement.textContent = this._commonPrefix.substring(this._userEnteredText.length); 525 this.acceptSuggestion(true) 526 }, 527 501 528 /** 502 529 * @param {Range=} originalPrefixRange … … 534 561 }, 535 562 536 acceptSuggestion: function() 563 /** 564 * @param {boolean=} prefixAccepted 565 */ 566 acceptSuggestion: function(prefixAccepted) 537 567 { 538 568 if (this._isAcceptingSuggestion) … … 555 585 selection.addRange(finalSelectionRange); 556 586 557 this.hideSuggestBox(); 558 this.dispatchEventToListeners(WebInspector.TextPrompt.Events.ItemAccepted); 587 if (!prefixAccepted) { 588 this.hideSuggestBox(); 589 this.dispatchEventToListeners(WebInspector.TextPrompt.Events.ItemAccepted); 590 } else 591 this.autoCompleteSoon(true); 559 592 560 593 return true; … … 664 697 tabKeyPressed: function(event) 665 698 { 666 // Just consume the key. 699 this._completeCommonPrefix(); 700 701 // Consume the key. 667 702 return true; 668 703 },
Note: See TracChangeset
for help on using the changeset viewer.