Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Make dialog-filename strings breakable #3446

Merged
merged 3 commits into from
Apr 17, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
always use htmlEscape in breakableUrl
  • Loading branch information
redmunds committed Apr 16, 2013
commit 1fb255f54fd8c60d35c18abf988ae39de6f910f1
4 changes: 2 additions & 2 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ define(function (require, exports, module) {
Strings.ERROR_SAVING_FILE_TITLE,
StringUtils.format(
Strings.ERROR_SAVING_FILE,
StringUtils.breakableUrl(StringUtils.htmlEscape(path)),
StringUtils.breakableUrl(path),
FileUtils.getFileErrorString(name)
)
);
Expand Down Expand Up @@ -578,7 +578,7 @@ define(function (require, exports, module) {
Strings.SAVE_CLOSE_TITLE,
StringUtils.format(
Strings.SAVE_CLOSE_MESSAGE,
StringUtils.breakableUrl(StringUtils.htmlEscape(filename))
StringUtils.breakableUrl(filename)
)
).done(function (id) {
if (id === Dialogs.DIALOG_BTN_CANCEL) {
Expand Down
2 changes: 1 addition & 1 deletion src/file/FileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ define(function (require, exports, module) {
Strings.ERROR_OPENING_FILE_TITLE,
StringUtils.format(
Strings.ERROR_OPENING_FILE,
StringUtils.breakableUrl(StringUtils.htmlEscape(path)),
StringUtils.breakableUrl(path),
getFileErrorString(name)
)
);
Expand Down
10 changes: 3 additions & 7 deletions src/project/FileSyncManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ define(function (require, exports, module) {
Strings.ERROR_RELOADING_FILE_TITLE,
StringUtils.format(
Strings.ERROR_RELOADING_FILE,
StringUtils.breakableUrl(StringUtils.htmlEscape(doc.file.fullPath)),
StringUtils.breakableUrl(doc.file.fullPath),
FileUtils.getFileErrorString(error.name)
)
);
Expand Down Expand Up @@ -265,9 +265,7 @@ define(function (require, exports, module) {
message = StringUtils.format(
Strings.EXT_MODIFIED_MESSAGE,
StringUtils.breakableUrl(
StringUtils.htmlEscape(
ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
)
ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
)
);

Expand All @@ -277,9 +275,7 @@ define(function (require, exports, module) {
message = StringUtils.format(
Strings.EXT_DELETED_MESSAGE,
StringUtils.breakableUrl(
StringUtils.htmlEscape(
ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
)
ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
)
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ define(function (require, exports, module) {
Strings.ERROR_LOADING_PROJECT,
StringUtils.format(
Strings.READ_DIRECTORY_ENTRIES_ERROR,
StringUtils.breakableUrl(StringUtils.htmlEscape(dirEntry.fullPath)),
StringUtils.breakableUrl(dirEntry.fullPath),
error.name
)
);
Expand Down Expand Up @@ -837,7 +837,7 @@ define(function (require, exports, module) {
Strings.ERROR_LOADING_PROJECT,
StringUtils.format(
Strings.REQUEST_NATIVE_FILE_SYSTEM_ERROR,
StringUtils.breakableUrl(StringUtils.htmlEscape(rootPath)),
StringUtils.breakableUrl(rootPath),
error.name
)
).done(function () {
Expand Down Expand Up @@ -1135,7 +1135,7 @@ define(function (require, exports, module) {
Strings.INVALID_FILENAME_TITLE,
StringUtils.format(
Strings.FILE_ALREADY_EXISTS,
StringUtils.breakableUrl(StringUtils.htmlEscape(data.rslt.name))
StringUtils.breakableUrl(data.rslt.name)
)
);
} else {
Expand All @@ -1145,7 +1145,7 @@ define(function (require, exports, module) {

var errMsg = StringUtils.format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might look better to just replace the errMsg in the Dialog, with these lines and not use the variable, since that is how it does everywhere else. If removing the errString variable too, is good, then we can combine it all without additional variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I got rid of errMsg, but left errString.

Strings.ERROR_CREATING_FILE,
StringUtils.breakableUrl(StringUtils.htmlEscape(data.rslt.name)),
StringUtils.breakableUrl(data.rslt.name),
errString
);

Expand Down Expand Up @@ -1277,7 +1277,7 @@ define(function (require, exports, module) {
Strings.ERROR_RENAMING_FILE_TITLE,
StringUtils.format(
Strings.ERROR_RENAMING_FILE,
StringUtils.breakableUrl(StringUtils.htmlEscape(newName)),
StringUtils.breakableUrl(newName),
err === brackets.fs.ERR_FILE_EXISTS ?
Strings.FILE_EXISTS_ERR :
FileUtils.getFileErrorString(err)
Expand Down
2 changes: 1 addition & 1 deletion src/search/FindInFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ define(function (require, exports, module) {

// Add row for file name
var displayFileName = StringUtils.format(Strings.FIND_IN_FILES_FILE_PATH,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will look nicer with a break after the ( and another break before the last ) of StringUtils.format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

StringUtils.breakableUrl(esc(item.fullPath)));
StringUtils.breakableUrl(item.fullPath));
$("<tr class='file-section' />")
.append("<td colspan='3'><span class='disclosure-triangle expanded'></span>" + displayFileName + "</td>")
.click(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/search/QuickOpen.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ define(function (require, exports, module) {
}

var rangeText = rangeFilter ? rangeFilter(range.includesLastSegment, range.text) : range.text;
displayName += StringUtils.breakableUrl(StringUtils.htmlEscape(rangeText));
displayName += StringUtils.breakableUrl(rangeText);

if (range.matched) {
displayName += "</span>";
Expand Down
7 changes: 5 additions & 2 deletions src/utils/StringUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,16 @@ define(function (require, exports, module) {
}

/**
* Return a path or URL string that can be broken near path separators.
* Return an escaped path or URL string that can be broken near path separators.
* @param {string} url the path or URL to format
* @return {string} the formatted path or URL
*/
function breakableUrl(url) {
// This is for displaying in UI, so always want it escaped
var escUrl = htmlEscape(url);

// Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there
return url.replace(
return escUrl.replace(
new RegExp(regexEscape("/"), "g"),
"/" + "&#8203;"
);
Expand Down