Repository navigation
Expand file tree
/
Copy pathhelper.js
More file actions
1 lines (1 loc) · 1.77 KB
/
Copy pathhelper.js
File metadata and controls
1 lines (1 loc) · 1.77 KB
1
define(function(require,exports,module){const WorkspaceManager=require("view/WorkspaceManager"),DocumentManager=require("document/DocumentManager"),ViewUtils=require("utils/ViewUtils"),WorkingSetView=require("project/WorkingSetView"),FileUtils=require("file/FileUtils");function _showTabBar($tabBar,$overflowButton){$tabBar&&($tabBar.show(),$overflowButton&&$overflowButton.show(),WorkspaceManager.recomputeLayout(!0))}function _hideTabBar($tabBar,$overflowButton){$tabBar&&($tabBar.hide(),$overflowButton&&$overflowButton.hide(),WorkspaceManager.recomputeLayout(!0))}function _getRequiredDataFromEntry(entry){return{path:entry.fullPath,name:entry.name,isFile:entry.isFile,isDirty:entry.isDirty,isPinned:entry.isPinned,displayName:entry.name}}function _isFileModified(file){const doc=DocumentManager.getOpenDocumentForPath(file.fullPath);return doc&&doc.isDirty}function _getFileIcon(fileData){const $link=$("<a href='#' class='mroitem'></a>").html(ViewUtils.getFileEntryDisplay({name:fileData.name}));return WorkingSetView.useIconProviders({fullPath:fileData.path,name:fileData.name,isFile:!0},$link),$link.children().first()}function _handleDuplicateFileNames(workingSet){const fileNameCount={};workingSet.forEach(entry=>{fileNameCount[entry.name]?fileNameCount[entry.name]++:fileNameCount[entry.name]=1}),workingSet.forEach(entry=>{if(fileNameCount[entry.name]>1){const path=entry.path,parentDir=FileUtils.getDirectoryPath(path),dirName=parentDir.split("/"),parentDirName=dirName[dirName.length-2]||"";entry.displayName=parentDirName+"/"+entry.name}else entry.displayName=entry.name})}module.exports={_showTabBar:_showTabBar,_hideTabBar:_hideTabBar,_getRequiredDataFromEntry:_getRequiredDataFromEntry,_isFileModified:_isFileModified,_getFileIcon:_getFileIcon,_handleDuplicateFileNames:_handleDuplicateFileNames}});