OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 if (this._suggestBox) | 465 if (this._suggestBox) |
466 this._suggestBox.updateSuggestions(this._boxForAnchorAtStart(selecti
on, fullWordRange), completions, selectedIndex, !this.isCaretAtEndOfPrompt(), th
is._userEnteredText); | 466 this._suggestBox.updateSuggestions(this._boxForAnchorAtStart(selecti
on, fullWordRange), completions, selectedIndex, !this.isCaretAtEndOfPrompt(), th
is._userEnteredText); |
467 | 467 |
468 if (selectedIndex === -1) | 468 if (selectedIndex === -1) |
469 return; | 469 return; |
470 | 470 |
471 var wordPrefixLength = originalWordPrefixRange.toString().length; | 471 var wordPrefixLength = originalWordPrefixRange.toString().length; |
472 this._commonPrefix = this._buildCommonPrefix(completions, wordPrefixLeng
th); | 472 this._commonPrefix = this._buildCommonPrefix(completions, wordPrefixLeng
th); |
473 | 473 |
474 if (this.isCaretAtEndOfPrompt()) { | 474 if (this.isCaretAtEndOfPrompt()) { |
| 475 var completionText = completions[selectedIndex]; |
| 476 var prefixText = this._userEnteredRange.toString(); |
| 477 var suffixText = completionText.substring(wordPrefixLength); |
475 this._userEnteredRange.deleteContents(); | 478 this._userEnteredRange.deleteContents(); |
476 this._element.normalize(); | 479 this._element.normalize(); |
477 var finalSelectionRange = document.createRange(); | 480 var finalSelectionRange = document.createRange(); |
478 var completionText = completions[selectedIndex]; | |
479 var prefixText = completionText.substring(0, wordPrefixLength); | |
480 var suffixText = completionText.substring(wordPrefixLength); | |
481 | 481 |
482 var prefixTextNode = document.createTextNode(prefixText); | 482 var prefixTextNode = document.createTextNode(prefixText); |
483 fullWordRange.insertNode(prefixTextNode); | 483 fullWordRange.insertNode(prefixTextNode); |
484 | 484 |
485 this.autoCompleteElement = document.createElementWithClass("span", "
auto-complete-text"); | 485 this.autoCompleteElement = document.createElementWithClass("span", "
auto-complete-text"); |
486 this.autoCompleteElement.textContent = suffixText; | 486 this.autoCompleteElement.textContent = suffixText; |
487 | 487 |
488 prefixTextNode.parentNode.insertBefore(this.autoCompleteElement, pre
fixTextNode.nextSibling); | 488 prefixTextNode.parentNode.insertBefore(this.autoCompleteElement, pre
fixTextNode.nextSibling); |
489 | 489 |
490 finalSelectionRange.setStart(prefixTextNode, wordPrefixLength); | 490 finalSelectionRange.setStart(prefixTextNode, wordPrefixLength); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 | 899 |
900 return; | 900 return; |
901 } | 901 } |
902 | 902 |
903 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); | 903 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); |
904 }, | 904 }, |
905 | 905 |
906 __proto__: WebInspector.TextPrompt.prototype | 906 __proto__: WebInspector.TextPrompt.prototype |
907 } | 907 } |
908 | 908 |
OLD | NEW |