@@ -5,7 +5,7 @@ const fs = require('fs')
55
66class Treeview {
77 constructor ( context ) {
8- const specTreeDataProvider = new SpecTreeDataProvider ( vscode . workspace . rootPath )
8+ const specTreeDataProvider = new SpecTreeDataProvider ( vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath )
99 context . subscriptions . push ( vscode . workspace . registerTextDocumentContentProvider ( 'spec' , specTreeDataProvider ) )
1010 this . specExplorer = vscode . window . createTreeView ( 'spec-explorer' , { treeDataProvider : specTreeDataProvider , showCollapseAll : true } )
1111 }
@@ -45,10 +45,10 @@ class SpecTreeDataProvider {
4545 }
4646
4747 getFiles ( thePath ) {
48- const toFileItem = ( name , path , type ) => {
48+ const toFileItem = ( name , targetPath , type ) => {
4949 if ( type == 'directory' ) {
5050 let descriptionText , collapsibleState
51- const filesCount = fs . readdirSync ( ` ${ path } \\ ${ name } ` ) . filter ( this . isMp3 ) . length
51+ const filesCount = fs . readdirSync ( path . join ( targetPath , name ) ) . filter ( this . isMp3 ) . length
5252 if ( filesCount > 0 ) {
5353 collapsibleState = vscode . TreeItemCollapsibleState . Collapsed
5454 descriptionText = `${ filesCount } song`
@@ -57,9 +57,9 @@ class SpecTreeDataProvider {
5757 collapsibleState = vscode . TreeItemCollapsibleState . None
5858 descriptionText = 'Empty'
5959 }
60- return new fileItem ( name , path , collapsibleState , descriptionText )
60+ return new fileItem ( name , targetPath , collapsibleState , descriptionText )
6161 } else {
62- return new fileItem ( name , path , vscode . TreeItemCollapsibleState . None )
62+ return new fileItem ( name , targetPath , vscode . TreeItemCollapsibleState . None )
6363 }
6464 }
6565 const isDirectory = name => fs . lstatSync ( path . join ( thePath , name ) ) . isDirectory ( )
@@ -84,13 +84,13 @@ class fileItem extends vscode.TreeItem {
8484 this . label = label
8585 this . collapsibleState = collapsibleState
8686 this . filePath = filePath
87- this . fullFilePath = ` ${ this . filePath } \\ ${ this . label } `
87+ this . fullFilePath = path . join ( this . filePath , this . label )
8888 this . command = command
8989 this . contextValue = 'dependency'
9090 this . descriptionText = descriptionText
9191 }
9292 get tooltip ( ) {
93- return ` ${ this . filePath } \\ ${ this . label } `
93+ return path . join ( this . filePath , this . label )
9494 }
9595 get description ( ) {
9696 return this . descriptionText
0 commit comments