Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Unified Diff: third_party/WebKit/Source/devtools/front_end/workspace/SearchConfig.js

Issue 2660853002: DevTools: fix search across all files in case of "file:" prefix (Closed)
Patch Set: use \s instead of space Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sources/search-config-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a85ef7a81de3e81d5f790036930549f299e6e343 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 = /"([^\\"]|\\.)+"/;
// 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 + '(\\s+' + unquotedWordPattern.source + ')*';
+
- var pattern = '(' + filePattern + ')|(' + quotedPattern + ')|(' + unquotedPattern + ')';
+ var pattern = [
+ '(\\s*' + Workspace.SearchConfig.FilePatternRegex.source + '\\s*)',
+ '(' + 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];
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)?:((?:[^\\ ]|\\.)+)/;
+
/** @typedef {!{regex: !RegExp, isNegative: boolean}} */
Workspace.SearchConfig.RegexQuery;
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sources/search-config-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698