Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/workspace/SearchConfig.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/SearchConfig.js b/third_party/WebKit/Source/devtools/front_end/workspace/SearchConfig.js |
| index 64e4912a67a03b8ab0294e1adc8fc85431474771..5277631b517f5f889caf15c3858c68d24c695014 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/workspace/SearchConfig.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/workspace/SearchConfig.js |
| @@ -58,20 +58,20 @@ Workspace.SearchConfig = class { |
| } |
| _parse() { |
| - var filePattern = |
| - '-?f(ile)?:(([^\\\\ ]|\\\\.)+)'; // After file: prefix: any symbol except space and backslash or any symbol escaped with a backslash. |
| - var quotedPattern = |
| - '"(([^\\\\"]|\\\\.)+)"'; // Inside double quotes: any symbol except double quote and backslash or any symbol escaped with a backslash. |
| - |
| + // Inside double quotes: any symbol except double quote and backslash or any symbol escaped with a backslash. |
| + var quotedPattern = /"([^\\"]|\\.)+"/; |
|
lushnikov
2017/01/30 10:03:42
these are just strings re-written as regex literal
|
| // A word is a sequence of any symbols except space and backslash or any symbols escaped with a backslash, that does not start with file:. |
| - var unquotedWordPattern = '(\\s*(?!-?f(ile)?:)[^\\\\ ]|\\\\.)+'; |
| - var unquotedPattern = |
| - unquotedWordPattern + '( +' + unquotedWordPattern + ')*'; // A word or several words separated by space(s). |
| + var unquotedWordPattern = /(\s*(?!-?f(ile)?:)[^\\ ]|\\.)+/; |
| + var unquotedPattern = unquotedWordPattern.source + '( +' + unquotedWordPattern.source + ')*'; |
|
dgozman
2017/01/30 16:54:42
I'm curious why we use ' ' instead of '\s' ?
lushnikov
2017/01/31 02:47:21
Looks like there's no good reason. Updated the CL
|
| + |
| - var pattern = '(' + filePattern + ')|(' + quotedPattern + ')|(' + unquotedPattern + ')'; |
| + var pattern = [ |
| + '(\\s*' + Workspace.SearchConfig.FilePatternRegex.source + '\\s*)', |
|
lushnikov
2017/01/30 10:03:42
the "\\s*" is the bugfix - swallowing of the white
|
| + '(' + quotedPattern.source + ')', |
| + '(' + unquotedPattern + ')', |
| + ].join('|'); |
| var regexp = new RegExp(pattern, 'g'); |
| var queryParts = this._query.match(regexp) || []; |
| - |
| /** |
| * @type {!Array.<!Workspace.SearchConfig.QueryTerm>} |
| */ |
| @@ -145,11 +145,11 @@ Workspace.SearchConfig = class { |
| * @return {?Workspace.SearchConfig.QueryTerm} |
| */ |
| _parseFileQuery(query) { |
| - var match = query.match(/^(-)?f(ile)?:/); |
| + var match = query.match(Workspace.SearchConfig.FilePatternRegex); |
| if (!match) |
| return null; |
| var isNegative = !!match[1]; |
| - query = query.substr(match[0].length); |
| + query = match[3]; |
|
lushnikov
2017/01/30 10:03:41
but here we still want to use only the actual file
|
| var result = ''; |
| for (var i = 0; i < query.length; ++i) { |
| var char = query[i]; |
| @@ -170,6 +170,9 @@ Workspace.SearchConfig = class { |
| } |
| }; |
| +// After file: prefix: any symbol except space and backslash or any symbol escaped with a backslash. |
| +Workspace.SearchConfig.FilePatternRegex = /(-)?f(ile)?:((?:[^\\ ]|\\.)+)/; |
|
lushnikov
2017/01/30 10:03:42
this is the "filePattern" regex, written as regex
|
| + |
| /** @typedef {!{regex: !RegExp, isNegative: boolean}} */ |
| Workspace.SearchConfig.RegexQuery; |