Skip to content

Commit c1655db

Browse files
committed
fix: truncate long directory names in working set
1 parent 9c5ad2a commit c1655db

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

src/project/WorkingSetView.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,27 +1000,39 @@ define(function (require, exports, module) {
10001000
}
10011001
};
10021002

1003+
10031004
/**
1004-
* Adds full directory names to elements representing passed files in working tree
1005+
* adds the directory name to external project files
1006+
* when the directory length is more than 3, we just show `...`
1007+
* otherwise the full path
10051008
* @private
1006-
* @param {Array.<string>} filesPathList - list of fullPath strings
1009+
* @param {Array.<string>} externalProjectFiles - the list of the external project files
10071010
*/
1008-
WorkingSetView.prototype._addFullDirectoryNamesToWorkingTreeFiles = function (filesPathList) {
1009-
// filesList must have at least two files in it for this to make sense
1010-
if (!filesPathList.length) {
1011+
WorkingSetView.prototype._addDirectoryNameToExternalProjectFiles = function (externalProjectFiles) {
1012+
if(!externalProjectFiles.length) {
10111013
return;
10121014
}
10131015

1014-
// Go through open files and add directories to appropriate entries
10151016
this.$openFilesContainer.find("ul > li").each(function () {
10161017
const $li = $(this);
10171018
let filePath = $li.data(_FILE_KEY).fullPath;
1018-
const io = filesPathList.indexOf(filePath);
1019+
const io = externalProjectFiles.indexOf(filePath);
10191020
if (io !== -1) {
10201021
let dirPath = path.dirname(filePath);
1021-
dirPath = Phoenix.app.getDisplayPath(dirPath);
1022-
const $dir = $(`<span title='${Phoenix.app.getDisplayPath(filePath)}' class='directory'/>`)
1023-
.html(" &mdash; " + dirPath);
1022+
// this will be displayed on hover
1023+
const displayPath = Phoenix.app.getDisplayPath(dirPath);
1024+
1025+
// use the platform specific separator for splitting
1026+
const separator = brackets.platform === "win" ? "\\" : "/";
1027+
let dirSplit = displayPath.split(separator);
1028+
1029+
let truncatedPath = displayPath; // truncatedPath value will be shown in the UI
1030+
if (dirSplit.length > 3) {
1031+
truncatedPath = dirSplit[0] + separator + "\u2026" + separator + dirSplit[dirSplit.length - 1];
1032+
}
1033+
1034+
const $dir = $(`<span title='${displayPath}' class='directory'/>`)
1035+
.html(" &mdash; " + truncatedPath);
10241036
$li.children("a").append($dir);
10251037
}
10261038
});
@@ -1084,7 +1096,7 @@ define(function (require, exports, module) {
10841096
}
10851097
});
10861098

1087-
self._addFullDirectoryNamesToWorkingTreeFiles(externalProjectFiles);
1099+
self._addDirectoryNameToExternalProjectFiles(externalProjectFiles);
10881100

10891101
// Go through the map and solve the arrays with length over 1. Ignore the rest.
10901102
_.forEach(map, function (value) {

0 commit comments

Comments
 (0)