Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing escaping so that code that bolds query within item works corre…

…ctly. Fixed up a few remaining references to "QuickFileOpen" and changed to QuickOpen
  • Loading branch information...
commit 1f63ea723e3823dce7ec8f9f6b66309bb6a3af80 1 parent f3f3a97
@tvoliter tvoliter authored
View
2  src/brackets.js
@@ -63,7 +63,7 @@ define(function (require, exports, module) {
CodeHintManager = require("editor/CodeHintManager"),
PerfUtils = require("utils/PerfUtils"),
FileIndexManager = require("project/FileIndexManager"),
- QuickFileOpen = require("search/QuickOpen"),
+ QuickOpen = require("search/QuickOpen"),
Menus = require("command/Menus"),
FileUtils = require("file/FileUtils"),
Strings = require("strings"),
View
2  src/extensions/default/README.txt
@@ -1,4 +1,4 @@
This directory contains extensions that ship with brackets and are enabled
-by default. Examples may include things like QuickFileOpen.
+by default. Examples include extensions for QuickOpen.
(README also serves as a dummy file so this directory can be added to git.)
View
2  src/search/FindInFiles.js
@@ -50,7 +50,7 @@ define(function (require, exports, module) {
EditorManager = require("editor/EditorManager"),
FileIndexManager = require("project/FileIndexManager");
- // This dialog class was mostly copied from QuickFileOpen. We should have a common dialog
+ // This dialog class was mostly copied from QuickOpen. We should have a common dialog
// class that everyone can use.
/**
View
38 src/search/QuickOpen.js
@@ -420,25 +420,47 @@ define(function (require, exports, module) {
}
function defaultResultsFormatter(item, query) {
- query = StringUtils.htmlEscape(query.slice(query.indexOf("@") + 1, query.length));
- var boldName = item.replace(new RegExp(query, "gi"), "<strong>$&</strong>");
- return "<li>" + boldName + "</li>";
+ query = query.slice(query.indexOf("@") + 1, query.length);
+
+ // Escape both query and item so the replace works properly below
+ query = StringUtils.htmlEscape(query);
+ item = StringUtils.htmlEscape(item);
+
+ var displayName;
+ if(query.length > 0 ) {
+ // make the users query bold within the item's text
+ displayName = item.replace(new RegExp(query, "gi"), "<strong>$&</strong>");
+ } else {
+ displayName = item;
+ }
+
+ return "<li>" + displayName + "</li>";
}
function _handleResultsFormatter(item) {
- var query = StringUtils.htmlEscape(($('input#quickOpenSearch').val()));
+ var query = $('input#quickOpenSearch').val();
if (currentPlugin) {
+ // Plugins use their own formatter or the default formatter
var formatter = currentPlugin.resultsFormatter || defaultResultsFormatter;
return formatter(item, query);
} else {
- // Format filename result
- var filename = _filenameFromPath(item, true);
+ // Use the filename formatter
+ query = StringUtils.htmlEscape(query);
+ var filename = StringUtils.htmlEscape(_filenameFromPath(item, true));
var rPath = StringUtils.htmlEscape(ProjectManager.makeProjectRelativeIfPossible(item));
- var boldName = filename.replace(new RegExp(query, "gi"), "<strong>$&</strong>");
- return "<li data-fullpath='" + encodeURIComponent(item) + "'>" + boldName +
+
+ var displayName;
+ if(query.length > 0 ) {
+ // make the users query bold within the item's text
+ displayName = filename.replace(new RegExp(query, "gi"), "<strong>$&</strong>");
+ } else {
+ displayName = filename;
+ }
+
+ return "<li data-fullpath='" + encodeURIComponent(item) + "'>" + displayName +
"<br><span class='quickOpenPath'>" + rPath + "</span></li>";
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.