[Question] How to get Treeview Selected Path?


#1

I’m trying to get the Current Selected Project in the ‘tree-view’ Portion.

atom.packages.getActivePackage('tree-view').mainModule.provideTreeView().selectedPaths()[0].split('\\').reverse()[0]

Is how i’m currently doing it.

I’m doing it inside of

atom.project.onDidChangePaths((projectPaths) => {
		 editor = atom.workspace.getActiveTextEditor();
		let data = atom.packages.getActivePackage('tree-view').mainModule.provideTreeView().selectedPaths()[0].split('\\').reverse()[0];
		projectName = data[0];
		//paths = atom.project.getPaths();
		//if(paths.length > 0) projectName = path.basename(paths[0]);
		//else projectName = null;
		
		updateData();
	});

But for whatever reason, It doesnt seem to work. Anyone have a Idea?


#2

It seems it has issues with the mainModule @.@


#3

@Bioblaze You should be using the tree-view API rather than trying to use the mainModule, which is unsupported.