Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 | * Copyright (C) 2007 Matt Lilek ([email protected]). |
| 4 | * Copyright (C) 2009 Joseph Pecoraro |
| 5 | * Copyright (C) 2011 Google Inc. All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 17 | * its contributors may be used to endorse or promote products derived |
| 18 | * from this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 21 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 23 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 32 | import * as Common from '../common/common.js'; |
Paul Lewis | 2d7d65c | 2020-03-16 17:26:30 | [diff] [blame^] | 33 | |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 34 | import {HistoryInput} from './HistoryInput.js'; |
| 35 | import {Toolbar, ToolbarButton, ToolbarToggle} from './Toolbar.js'; |
| 36 | import {createTextButton} from './UIUtils.js'; |
| 37 | import {VBox} from './Widget.js'; |
| 38 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 39 | /** |
| 40 | * @unrestricted |
| 41 | */ |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 42 | export class SearchableView extends VBox { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 43 | /** |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 44 | * @param {!Searchable} searchable |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 45 | * @param {string=} settingName |
| 46 | */ |
| 47 | constructor(searchable, settingName) { |
| 48 | super(true); |
| 49 | this.registerRequiredCSS('ui/searchableView.css'); |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 50 | this.element[_symbol] = this; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 51 | |
| 52 | this._searchProvider = searchable; |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 53 | // Note: go via self.Common for globally-namespaced singletons. |
Paul Lewis | 2d7d65c | 2020-03-16 17:26:30 | [diff] [blame^] | 54 | this._setting = settingName ? Common.Settings.Settings.instance().createSetting(settingName, {}) : null; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 55 | this._replaceable = false; |
| 56 | |
Joel Einbinder | 7fbe24c | 2019-01-24 05:19:01 | [diff] [blame] | 57 | this.contentElement.createChild('slot'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 58 | this._footerElementContainer = this.contentElement.createChild('div', 'search-bar hidden'); |
| 59 | this._footerElementContainer.style.order = 100; |
| 60 | this._footerElement = this._footerElementContainer.createChild('div', 'toolbar-search'); |
| 61 | |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 62 | const replaceToggleToolbar = new Toolbar('replace-toggle-toolbar', this._footerElement); |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 63 | this._replaceToggleButton = new ToolbarToggle(Common.UIString.UIString('Replace'), 'mediumicon-replace'); |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 64 | this._replaceToggleButton.addEventListener(ToolbarButton.Events.Click, this._toggleReplace, this); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 65 | replaceToggleToolbar.appendToolbarItem(this._replaceToggleButton); |
| 66 | |
| 67 | const searchInputElements = this._footerElement.createChild('div', 'toolbar-search-inputs'); |
| 68 | const searchControlElement = searchInputElements.createChild('div', 'toolbar-search-control'); |
| 69 | |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 70 | this._searchInputElement = HistoryInput.create(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 71 | this._searchInputElement.classList.add('search-replace'); |
| 72 | this._searchInputElement.id = 'search-input-field'; |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 73 | this._searchInputElement.placeholder = Common.UIString.UIString('Find'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 74 | searchControlElement.appendChild(this._searchInputElement); |
| 75 | |
| 76 | this._matchesElement = searchControlElement.createChild('label', 'search-results-matches'); |
| 77 | this._matchesElement.setAttribute('for', 'search-input-field'); |
| 78 | |
| 79 | const searchNavigationElement = searchControlElement.createChild('div', 'toolbar-search-navigation-controls'); |
| 80 | |
| 81 | this._searchNavigationPrevElement = |
| 82 | searchNavigationElement.createChild('div', 'toolbar-search-navigation toolbar-search-navigation-prev'); |
| 83 | this._searchNavigationPrevElement.addEventListener('click', this._onPrevButtonSearch.bind(this), false); |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 84 | this._searchNavigationPrevElement.title = Common.UIString.UIString('Search previous'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 85 | |
| 86 | this._searchNavigationNextElement = |
| 87 | searchNavigationElement.createChild('div', 'toolbar-search-navigation toolbar-search-navigation-next'); |
| 88 | this._searchNavigationNextElement.addEventListener('click', this._onNextButtonSearch.bind(this), false); |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 89 | this._searchNavigationNextElement.title = Common.UIString.UIString('Search next'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 90 | |
| 91 | this._searchInputElement.addEventListener('keydown', this._onSearchKeyDown.bind(this), true); |
| 92 | this._searchInputElement.addEventListener('input', this._onInput.bind(this), false); |
| 93 | |
| 94 | this._replaceInputElement = |
| 95 | searchInputElements.createChild('input', 'search-replace toolbar-replace-control hidden'); |
| 96 | this._replaceInputElement.addEventListener('keydown', this._onReplaceKeyDown.bind(this), true); |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 97 | this._replaceInputElement.placeholder = Common.UIString.UIString('Replace'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 98 | |
| 99 | this._buttonsContainer = this._footerElement.createChild('div', 'toolbar-search-buttons'); |
| 100 | const firstRowButtons = this._buttonsContainer.createChild('div', 'first-row-buttons'); |
| 101 | |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 102 | const toolbar = new Toolbar('toolbar-search-options', firstRowButtons); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 103 | |
| 104 | if (this._searchProvider.supportsCaseSensitiveSearch()) { |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 105 | this._caseSensitiveButton = new ToolbarToggle(Common.UIString.UIString('Match Case')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 106 | this._caseSensitiveButton.setText('Aa'); |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 107 | this._caseSensitiveButton.addEventListener(ToolbarButton.Events.Click, this._toggleCaseSensitiveSearch, this); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 108 | toolbar.appendToolbarItem(this._caseSensitiveButton); |
| 109 | } |
| 110 | |
| 111 | if (this._searchProvider.supportsRegexSearch()) { |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 112 | this._regexButton = new ToolbarToggle(Common.UIString.UIString('Use Regular Expression')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 113 | this._regexButton.setText('.*'); |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 114 | this._regexButton.addEventListener(ToolbarButton.Events.Click, this._toggleRegexSearch, this); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 115 | toolbar.appendToolbarItem(this._regexButton); |
| 116 | } |
| 117 | |
| 118 | const cancelButtonElement = |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 119 | createTextButton(Common.UIString.UIString('Cancel'), this.closeSearch.bind(this), 'search-action-button'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 120 | firstRowButtons.appendChild(cancelButtonElement); |
| 121 | |
| 122 | this._secondRowButtons = this._buttonsContainer.createChild('div', 'second-row-buttons hidden'); |
| 123 | |
| 124 | this._replaceButtonElement = |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 125 | createTextButton(Common.UIString.UIString('Replace'), this._replace.bind(this), 'search-action-button'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 126 | this._replaceButtonElement.disabled = true; |
| 127 | this._secondRowButtons.appendChild(this._replaceButtonElement); |
| 128 | |
| 129 | this._replaceAllButtonElement = |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 130 | createTextButton(Common.UIString.UIString('Replace all'), this._replaceAll.bind(this), 'search-action-button'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 131 | this._secondRowButtons.appendChild(this._replaceAllButtonElement); |
| 132 | this._replaceAllButtonElement.disabled = true; |
| 133 | |
| 134 | this._minimalSearchQuerySize = 3; |
| 135 | this._loadSetting(); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * @param {?Element} element |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 140 | * @return {?SearchableView} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 141 | */ |
| 142 | static fromElement(element) { |
| 143 | let view = null; |
| 144 | while (element && !view) { |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 145 | view = element[_symbol]; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 146 | element = element.parentElementOrShadowHost(); |
| 147 | } |
| 148 | return view; |
| 149 | } |
| 150 | |
| 151 | _toggleCaseSensitiveSearch() { |
| 152 | this._caseSensitiveButton.setToggled(!this._caseSensitiveButton.toggled()); |
| 153 | this._saveSetting(); |
| 154 | this._performSearch(false, true); |
| 155 | } |
| 156 | |
| 157 | _toggleRegexSearch() { |
| 158 | this._regexButton.setToggled(!this._regexButton.toggled()); |
| 159 | this._saveSetting(); |
| 160 | this._performSearch(false, true); |
| 161 | } |
| 162 | |
| 163 | _toggleReplace() { |
| 164 | this._replaceToggleButton.setToggled(!this._replaceToggleButton.toggled()); |
| 165 | this._updateSecondRowVisibility(); |
| 166 | } |
| 167 | |
| 168 | _saveSetting() { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 169 | if (!this._setting) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 170 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 171 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 172 | const settingValue = this._setting.get() || {}; |
| 173 | settingValue.caseSensitive = this._caseSensitiveButton.toggled(); |
| 174 | settingValue.isRegex = this._regexButton.toggled(); |
| 175 | this._setting.set(settingValue); |
| 176 | } |
| 177 | |
| 178 | _loadSetting() { |
| 179 | const settingValue = this._setting ? (this._setting.get() || {}) : {}; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 180 | if (this._searchProvider.supportsCaseSensitiveSearch()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 181 | this._caseSensitiveButton.setToggled(!!settingValue.caseSensitive); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 182 | } |
| 183 | if (this._searchProvider.supportsRegexSearch()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 184 | this._regexButton.setToggled(!!settingValue.isRegex); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 185 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | /** |
| 189 | * @param {number} minimalSearchQuerySize |
| 190 | */ |
| 191 | setMinimalSearchQuerySize(minimalSearchQuerySize) { |
| 192 | this._minimalSearchQuerySize = minimalSearchQuerySize; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * @param {string} placeholder |
| 197 | */ |
| 198 | setPlaceholder(placeholder) { |
| 199 | this._searchInputElement.placeholder = placeholder; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * @param {boolean} replaceable |
| 204 | */ |
| 205 | setReplaceable(replaceable) { |
| 206 | this._replaceable = replaceable; |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * @param {number} matches |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 211 | * @suppress {checkTypes} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 212 | */ |
| 213 | updateSearchMatchesCount(matches) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 214 | if (this._searchProvider.currentSearchMatches === matches) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 215 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 216 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 217 | this._searchProvider.currentSearchMatches = matches; |
| 218 | this._updateSearchMatchesCountAndCurrentMatchIndex(this._searchProvider.currentQuery ? matches : 0, -1); |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * @param {number} currentMatchIndex |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 223 | * @suppress {checkTypes} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 224 | */ |
| 225 | updateCurrentMatchIndex(currentMatchIndex) { |
| 226 | this._updateSearchMatchesCountAndCurrentMatchIndex(this._searchProvider.currentSearchMatches, currentMatchIndex); |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * @return {boolean} |
| 231 | */ |
| 232 | isSearchVisible() { |
| 233 | return this._searchIsVisible; |
| 234 | } |
| 235 | |
| 236 | closeSearch() { |
| 237 | this.cancelSearch(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 238 | if (this._footerElementContainer.hasFocus()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 239 | this.focus(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 240 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | _toggleSearchBar(toggled) { |
| 244 | this._footerElementContainer.classList.toggle('hidden', !toggled); |
| 245 | this.doResize(); |
| 246 | } |
| 247 | |
| 248 | cancelSearch() { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 249 | if (!this._searchIsVisible) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 250 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 251 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 252 | this.resetSearch(); |
| 253 | delete this._searchIsVisible; |
| 254 | this._toggleSearchBar(false); |
| 255 | } |
| 256 | |
| 257 | resetSearch() { |
| 258 | this._clearSearch(); |
| 259 | this._updateReplaceVisibility(); |
| 260 | this._matchesElement.textContent = ''; |
| 261 | } |
| 262 | |
| 263 | refreshSearch() { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 264 | if (!this._searchIsVisible) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 265 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 266 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 267 | this.resetSearch(); |
| 268 | this._performSearch(false, false); |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * @return {boolean} |
| 273 | */ |
| 274 | handleFindNextShortcut() { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 275 | if (!this._searchIsVisible) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 276 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 277 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 278 | this._searchProvider.jumpToNextSearchResult(); |
| 279 | return true; |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * @return {boolean} |
| 284 | */ |
| 285 | handleFindPreviousShortcut() { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 286 | if (!this._searchIsVisible) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 287 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 288 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 289 | this._searchProvider.jumpToPreviousSearchResult(); |
| 290 | return true; |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * @return {boolean} |
| 295 | */ |
| 296 | handleFindShortcut() { |
| 297 | this.showSearchField(); |
| 298 | return true; |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * @return {boolean} |
| 303 | */ |
| 304 | handleCancelSearchShortcut() { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 305 | if (!this._searchIsVisible) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 306 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 307 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 308 | this.closeSearch(); |
| 309 | return true; |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * @param {boolean} enabled |
| 314 | */ |
| 315 | _updateSearchNavigationButtonState(enabled) { |
| 316 | this._replaceButtonElement.disabled = !enabled; |
| 317 | this._replaceAllButtonElement.disabled = !enabled; |
| 318 | this._searchNavigationPrevElement.classList.toggle('enabled', enabled); |
| 319 | this._searchNavigationNextElement.classList.toggle('enabled', enabled); |
| 320 | } |
| 321 | |
| 322 | /** |
| 323 | * @param {number} matches |
| 324 | * @param {number} currentMatchIndex |
| 325 | */ |
| 326 | _updateSearchMatchesCountAndCurrentMatchIndex(matches, currentMatchIndex) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 327 | if (!this._currentQuery) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 328 | this._matchesElement.textContent = ''; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 329 | } else if (matches === 0 || currentMatchIndex >= 0) { |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 330 | this._matchesElement.textContent = Common.UIString.UIString('%d of %d', currentMatchIndex + 1, matches); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 331 | } else if (matches === 1) { |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 332 | this._matchesElement.textContent = Common.UIString.UIString('1 match'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 333 | } else { |
Paul Lewis | 17e384e | 2020-01-08 15:46:51 | [diff] [blame] | 334 | this._matchesElement.textContent = Common.UIString.UIString('%d matches', matches); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 335 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 336 | this._updateSearchNavigationButtonState(matches > 0); |
| 337 | } |
| 338 | |
| 339 | showSearchField() { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 340 | if (this._searchIsVisible) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 341 | this.cancelSearch(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 342 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 343 | |
| 344 | let queryCandidate; |
| 345 | if (!this._searchInputElement.hasFocus()) { |
Paul Lewis | 0a7c6b6 | 2020-01-23 16:16:22 | [diff] [blame] | 346 | const selection = self.UI.inspectorView.element.window().getSelection(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 347 | if (selection.rangeCount) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 348 | queryCandidate = selection.toString().replace(/\r?\n.*/, ''); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 349 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | this._toggleSearchBar(true); |
| 353 | this._updateReplaceVisibility(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 354 | if (queryCandidate) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 355 | this._searchInputElement.value = queryCandidate; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 356 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 357 | this._performSearch(false, false); |
| 358 | this._searchInputElement.focus(); |
| 359 | this._searchInputElement.select(); |
| 360 | this._searchIsVisible = true; |
| 361 | } |
| 362 | |
| 363 | _updateReplaceVisibility() { |
| 364 | this._replaceToggleButton.setVisible(this._replaceable); |
| 365 | if (!this._replaceable) { |
| 366 | this._replaceToggleButton.setToggled(false); |
| 367 | this._updateSecondRowVisibility(); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | /** |
| 372 | * @param {!Event} event |
| 373 | */ |
| 374 | _onSearchKeyDown(event) { |
| 375 | if (isEscKey(event)) { |
| 376 | this.closeSearch(); |
| 377 | event.consume(true); |
| 378 | return; |
| 379 | } |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 380 | if (!isEnterKey(event)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 381 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 382 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 383 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 384 | if (!this._currentQuery) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 385 | this._performSearch(true, true, event.shiftKey); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 386 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 387 | this._jumpToNextSearchResult(event.shiftKey); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 388 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | /** |
| 392 | * @param {!Event} event |
| 393 | */ |
| 394 | _onReplaceKeyDown(event) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 395 | if (isEnterKey(event)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 396 | this._replace(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 397 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | /** |
| 401 | * @param {boolean=} isBackwardSearch |
| 402 | */ |
| 403 | _jumpToNextSearchResult(isBackwardSearch) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 404 | if (!this._currentQuery) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 405 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 406 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 407 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 408 | if (isBackwardSearch) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 409 | this._searchProvider.jumpToPreviousSearchResult(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 410 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 411 | this._searchProvider.jumpToNextSearchResult(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 412 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | _onNextButtonSearch(event) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 416 | if (!this._searchNavigationNextElement.classList.contains('enabled')) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 417 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 418 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 419 | this._jumpToNextSearchResult(); |
| 420 | this._searchInputElement.focus(); |
| 421 | } |
| 422 | |
| 423 | _onPrevButtonSearch(event) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 424 | if (!this._searchNavigationPrevElement.classList.contains('enabled')) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 425 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 426 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 427 | this._jumpToNextSearchResult(true); |
| 428 | this._searchInputElement.focus(); |
| 429 | } |
| 430 | |
| 431 | _onFindClick(event) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 432 | if (!this._currentQuery) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 433 | this._performSearch(true, true); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 434 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 435 | this._jumpToNextSearchResult(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 436 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 437 | this._searchInputElement.focus(); |
| 438 | } |
| 439 | |
| 440 | _onPreviousClick(event) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 441 | if (!this._currentQuery) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 442 | this._performSearch(true, true, true); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 443 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 444 | this._jumpToNextSearchResult(true); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 445 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 446 | this._searchInputElement.focus(); |
| 447 | } |
| 448 | |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 449 | /** @suppress {checkTypes} */ |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 450 | _clearSearch() { |
| 451 | delete this._currentQuery; |
| 452 | if (!!this._searchProvider.currentQuery) { |
| 453 | delete this._searchProvider.currentQuery; |
| 454 | this._searchProvider.searchCanceled(); |
| 455 | } |
| 456 | this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1); |
| 457 | } |
| 458 | |
| 459 | /** |
| 460 | * @param {boolean} forceSearch |
| 461 | * @param {boolean} shouldJump |
| 462 | * @param {boolean=} jumpBackwards |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 463 | * @suppress {checkTypes} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 464 | */ |
| 465 | _performSearch(forceSearch, shouldJump, jumpBackwards) { |
| 466 | const query = this._searchInputElement.value; |
| 467 | if (!query || (!forceSearch && query.length < this._minimalSearchQuerySize && !this._currentQuery)) { |
| 468 | this._clearSearch(); |
| 469 | return; |
| 470 | } |
| 471 | |
| 472 | this._currentQuery = query; |
| 473 | this._searchProvider.currentQuery = query; |
| 474 | |
| 475 | const searchConfig = this._currentSearchConfig(); |
| 476 | this._searchProvider.performSearch(searchConfig, shouldJump, jumpBackwards); |
| 477 | } |
| 478 | |
| 479 | /** |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 480 | * @return {!SearchConfig} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 481 | */ |
| 482 | _currentSearchConfig() { |
| 483 | const query = this._searchInputElement.value; |
| 484 | const caseSensitive = this._caseSensitiveButton ? this._caseSensitiveButton.toggled() : false; |
| 485 | const isRegex = this._regexButton ? this._regexButton.toggled() : false; |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 486 | return new SearchConfig(query, caseSensitive, isRegex); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | _updateSecondRowVisibility() { |
| 490 | const secondRowVisible = this._replaceToggleButton.toggled(); |
| 491 | this._footerElementContainer.classList.toggle('replaceable', secondRowVisible); |
| 492 | this._secondRowButtons.classList.toggle('hidden', !secondRowVisible); |
| 493 | this._replaceInputElement.classList.toggle('hidden', !secondRowVisible); |
| 494 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 495 | if (secondRowVisible) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 496 | this._replaceInputElement.focus(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 497 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 498 | this._searchInputElement.focus(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 499 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 500 | this.doResize(); |
| 501 | } |
| 502 | |
| 503 | _replace() { |
| 504 | const searchConfig = this._currentSearchConfig(); |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 505 | /** @type {!Replaceable} */ (this._searchProvider) |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 506 | .replaceSelectionWith(searchConfig, this._replaceInputElement.value); |
| 507 | delete this._currentQuery; |
| 508 | this._performSearch(true, true); |
| 509 | } |
| 510 | |
| 511 | _replaceAll() { |
| 512 | const searchConfig = this._currentSearchConfig(); |
Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame] | 513 | /** @type {!Replaceable} */ (this._searchProvider).replaceAllWith(searchConfig, this._replaceInputElement.value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | /** |
| 517 | * @param {!Event} event |
| 518 | */ |
| 519 | _onInput(event) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 520 | if (this._valueChangedTimeoutId) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 521 | clearTimeout(this._valueChangedTimeoutId); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 522 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 523 | const timeout = this._searchInputElement.value.length < 3 ? 200 : 0; |
| 524 | this._valueChangedTimeoutId = setTimeout(this._onValueChanged.bind(this), timeout); |
| 525 | } |
| 526 | |
| 527 | _onValueChanged() { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 528 | if (!this._searchIsVisible) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 529 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 530 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 531 | delete this._valueChangedTimeoutId; |
| 532 | this._performSearch(false, true); |
| 533 | } |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 534 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 535 | |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 536 | export const _symbol = Symbol('searchableView'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 537 | |
| 538 | |
| 539 | /** |
| 540 | * @interface |
| 541 | */ |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 542 | export class Searchable { |
| 543 | searchCanceled() { |
| 544 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 545 | |
| 546 | /** |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 547 | * @param {!SearchConfig} searchConfig |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 548 | * @param {boolean} shouldJump |
| 549 | * @param {boolean=} jumpBackwards |
| 550 | */ |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 551 | performSearch(searchConfig, shouldJump, jumpBackwards) { |
| 552 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 553 | |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 554 | jumpToNextSearchResult() { |
| 555 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 556 | |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 557 | jumpToPreviousSearchResult() { |
| 558 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 559 | |
| 560 | /** |
| 561 | * @return {boolean} |
| 562 | */ |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 563 | supportsCaseSensitiveSearch() { |
| 564 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 565 | |
| 566 | /** |
| 567 | * @return {boolean} |
| 568 | */ |
| 569 | supportsRegexSearch() {} |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 570 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 571 | |
| 572 | /** |
| 573 | * @interface |
| 574 | */ |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 575 | export class Replaceable { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 576 | /** |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 577 | * @param {!SearchConfig} searchConfig |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 578 | * @param {string} replacement |
| 579 | */ |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 580 | replaceSelectionWith(searchConfig, replacement) { |
| 581 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 582 | |
| 583 | /** |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 584 | * @param {!SearchConfig} searchConfig |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 585 | * @param {string} replacement |
| 586 | */ |
| 587 | replaceAllWith(searchConfig, replacement) {} |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 588 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 589 | |
| 590 | /** |
| 591 | * @unrestricted |
| 592 | */ |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 593 | export class SearchConfig { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 594 | /** |
| 595 | * @param {string} query |
| 596 | * @param {boolean} caseSensitive |
| 597 | * @param {boolean} isRegex |
| 598 | */ |
| 599 | constructor(query, caseSensitive, isRegex) { |
| 600 | this.query = query; |
| 601 | this.caseSensitive = caseSensitive; |
| 602 | this.isRegex = isRegex; |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * @param {boolean=} global |
| 607 | * @return {!RegExp} |
| 608 | */ |
| 609 | toSearchRegex(global) { |
| 610 | let modifiers = this.caseSensitive ? '' : 'i'; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 611 | if (global) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 612 | modifiers += 'g'; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 613 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 614 | const query = this.isRegex ? '/' + this.query + '/' : this.query; |
| 615 | |
| 616 | let regex; |
| 617 | |
| 618 | // First try creating regex if user knows the / / hint. |
| 619 | try { |
| 620 | if (/^\/.+\/$/.test(query)) { |
| 621 | regex = new RegExp(query.substring(1, query.length - 1), modifiers); |
| 622 | regex.__fromRegExpQuery = true; |
| 623 | } |
| 624 | } catch (e) { |
| 625 | // Silent catch. |
| 626 | } |
| 627 | |
| 628 | // Otherwise just do a plain text search. |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 629 | if (!regex) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 630 | regex = createPlainTextSearchRegex(query, modifiers); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 631 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 632 | |
| 633 | return regex; |
| 634 | } |
Tim van der Lippe | 0830b3d | 2019-10-03 13:20:07 | [diff] [blame] | 635 | } |