import { StatusBarAlignment , StatusBarItem , window , workspace } from "vscode" ; import { Locators } from "../vscode-project-manager-core/src/autodetect/locators" ; import { ProjectStorage } from "../vscode-project-manager-core/src/storage" ; import { codicons } from "vscode-ext-codicons" ; import { isRemoteUri } from "../vscode-project-manager-core/src/utils/remote" ; import { getCodiconFromUri } from "../vscode-project-manager-core/src/icons" ; import { Project } from "../vscode-project-manager-core/src/project" ; let statusItem ; export function showStatusBar ( projectStorage , locators , projectName ? ) { const showStatusConfig = workspace . getConfiguration ( "projectManager" ) . get ( "showProjectNameInStatusBar" ) ; const workspace0 = workspace . workspaceFile ? workspace . workspaceFile : workspace . workspaceFolders ? workspace . workspaceFolders [ 0 ] . uri : undefined ; const currentProjectPath = workspace0 ? workspace0 . fsPath : undefined ; if ( ! showStatusConfig || ! currentProjectPath ) { return ; } if ( ! statusItem ) { statusItem = window . createStatusBarItem ( "projectManager.statusBar" , StatusBarAlignment . Left ) ; statusItem . name = "Project Manager" ; } statusItem . text = getCodiconFromUri ( workspace0 ) + " " ; statusItem . tooltip = currentProjectPath ; const openInNewWindow = workspace . getConfiguration ( "projectManager" ) . get ( "openInNewWindowWhenClickingInStatusBar" , false ) ; if ( openInNewWindow ) { statusItem . command = "projectManager.listProjectsNewWindow" ; } else { statusItem . command = "projectManager.listProjects" ; } if ( projectName ) { statusItem . text += projectName ; statusItem . show ( ) ; return ; } let foundProject ; if ( isRemoteUri ( workspace0 ) ) { foundProject = projectStorage . existsRemoteWithRootPath ( workspace0 ) ; } else { foundProject = projectStorage . existsWithRootPath ( currentProjectPath ) ; if ( ! foundProject ) { foundProject = locators . vscLocator . existsWithRootPath ( currentProjectPath ) ; } if ( ! foundProject ) { foundProject = locators . gitLocator . existsWithRootPath ( currentProjectPath ) ; } if ( ! foundProject ) { foundProject = locators . mercurialLocator . existsWithRootPath ( currentProjectPath ) ; } if ( ! foundProject ) { foundProject = locators . svnLocator . existsWithRootPath ( currentProjectPath ) ; } if ( ! foundProject ) { foundProject = locators . anyLocator . existsWithRootPath ( currentProjectPath ) ; } } if ( foundProject ) { statusItem . text += foundProject . name ; statusItem . show ( ) ; } } export function updateStatusBar ( oldName , oldPath , newName ) { if ( statusItem . text === codicons . file_directory + " " + oldName && statusItem . tooltip === oldPath ) { statusItem . text = codicons . file_directory + " " + newName ; } }