| 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 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 /** | 807 /** |
| 808 * @type {!Array.<string>} | 808 * @type {!Array.<string>} |
| 809 */ | 809 */ |
| 810 this._data = []; | 810 this._data = []; |
| 811 | 811 |
| 812 /** | 812 /** |
| 813 * 1-based entry in the history stack. | 813 * 1-based entry in the history stack. |
| 814 * @type {number} | 814 * @type {number} |
| 815 */ | 815 */ |
| 816 this._historyOffset = 1; | 816 this._historyOffset = 1; |
| 817 |
| 818 this._addCompletionsFromHistory = true; |
| 817 } | 819 } |
| 818 | 820 |
| 819 WebInspector.TextPromptWithHistory.prototype = { | 821 WebInspector.TextPromptWithHistory.prototype = { |
| 820 /** | 822 /** |
| 821 * @return {!Array.<string>} | 823 * @return {!Array.<string>} |
| 822 */ | 824 */ |
| 823 historyData: function() | 825 historyData: function() |
| 824 { | 826 { |
| 825 // FIXME: do we need to copy this? | 827 // FIXME: do we need to copy this? |
| 826 return this._data; | 828 return this._data; |
| 827 }, | 829 }, |
| 828 | 830 |
| 829 /** | 831 /** |
| 830 * @override | 832 * @override |
| 831 * @param {string} prefix | 833 * @param {string} prefix |
| 832 * @return {!WebInspector.SuggestBox.Suggestions} | 834 * @return {!WebInspector.SuggestBox.Suggestions} |
| 833 */ | 835 */ |
| 834 additionalCompletions: function(prefix) | 836 additionalCompletions: function(prefix) |
| 835 { | 837 { |
| 836 if (!this.isCaretAtEndOfPrompt()) | 838 if (!this._addCompletionsFromHistory || !this.isCaretAtEndOfPrompt()) |
| 837 return []; | 839 return []; |
| 838 var result = []; | 840 var result = []; |
| 839 var text = this.text(); | 841 var text = this.text(); |
| 840 var set = new Set(); | 842 var set = new Set(); |
| 841 for (var i = this._data.length - 1; i >= 0 && result.length < 50; --i) { | 843 for (var i = this._data.length - 1; i >= 0 && result.length < 50; --i) { |
| 842 var item = this._data[i]; | 844 var item = this._data[i]; |
| 843 if (!item.startsWith(text)) | 845 if (!item.startsWith(text)) |
| 844 continue; | 846 continue; |
| 845 if (set.has(item)) | 847 if (set.has(item)) |
| 846 continue; | 848 continue; |
| 847 set.add(item); | 849 set.add(item); |
| 848 result.push({title: item.substring(text.length - prefix.length), cla
ssName: "additional"}); | 850 result.push({title: item.substring(text.length - prefix.length), cla
ssName: "additional"}); |
| 849 } | 851 } |
| 850 return result; | 852 return result; |
| 851 }, | 853 }, |
| 852 | 854 |
| 853 /** | 855 /** |
| 854 * @param {!Array.<string>} data | 856 * @param {!Array.<string>} data |
| 855 */ | 857 */ |
| 856 setHistoryData: function(data) | 858 setHistoryData: function(data) |
| 857 { | 859 { |
| 858 this._data = [].concat(data); | 860 this._data = [].concat(data); |
| 859 this._historyOffset = 1; | 861 this._historyOffset = 1; |
| 860 }, | 862 }, |
| 861 | 863 |
| 862 /** | 864 /** |
| 865 * @param {boolean} value |
| 866 */ |
| 867 setAddCompletionsFromHistory: function(value) |
| 868 { |
| 869 this._addCompletionsFromHistory = value; |
| 870 }, |
| 871 |
| 872 /** |
| 863 * Pushes a committed text into the history. | 873 * Pushes a committed text into the history. |
| 864 * @param {string} text | 874 * @param {string} text |
| 865 */ | 875 */ |
| 866 pushHistoryItem: function(text) | 876 pushHistoryItem: function(text) |
| 867 { | 877 { |
| 868 if (this._uncommittedIsTop) { | 878 if (this._uncommittedIsTop) { |
| 869 this._data.pop(); | 879 this._data.pop(); |
| 870 delete this._uncommittedIsTop; | 880 delete this._uncommittedIsTop; |
| 871 } | 881 } |
| 872 | 882 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 | 984 |
| 975 return; | 985 return; |
| 976 } | 986 } |
| 977 | 987 |
| 978 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); | 988 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); |
| 979 }, | 989 }, |
| 980 | 990 |
| 981 __proto__: WebInspector.TextPrompt.prototype | 991 __proto__: WebInspector.TextPrompt.prototype |
| 982 } | 992 } |
| 983 | 993 |
| OLD | NEW |