@@ -5,12 +5,6 @@ var i = 0;
55var sb = null ;
66
77function OnCommand ( textEditor ) {
8-
9- var config = vscode . workspace . getConfiguration ( 'ActiveFileInStatusBar' ) ;
10- var cmd = vscode . commands . getCommands ( ) ;
11- cmd . then ( function ( a , b , c ) {
12- console . log ( a ) ;
13- } ) ;
148}
159
1610function OnStatusBarUpdate ( textEditor ) {
@@ -25,31 +19,44 @@ function OnStatusBarUpdate( textEditor ) {
2519 if ( ! config . fullpath && vscode . workspace . rootPath ) {
2620 filePath = path . relative ( vscode . workspace . rootPath , textEditor . document . fileName ) ;
2721 }
28- sb . text = filePath ;
22+ var icon = '$(clippy)' ;
23+ sb . tooltip = 'Copy active file to clipboard' ;
24+ if ( config . revealFile ) {
25+ icon = '$(file-submodule)' ;
26+ sb . tooltip = 'Reveal file' ;
27+ }
28+ sb . text = icon + ' ' + filePath ;
2929 sb . show ( ) ;
3030 }
3131 console . log ( "TextEdit : " + sb . text ) ;
3232 }
3333}
3434
3535function CreateStatusBar ( ) {
36- vscode . commands . registerTextEditorCommand ( "extension.ActiveFileInStatusBar.OnCommand" , OnCommand ) ;
36+ var config = vscode . workspace . getConfiguration ( 'ActiveFileInStatusBar' ) ;
37+ // vscode.commands.registerTextEditorCommand("extension.ActiveFileInStatusBar.OnCommand", OnCommand);
3738 var sb = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left ) ;
3839 sb . text = '' ;
39- sb . command = "extension.ActiveFileInStatusBar.OnCommand" ; // 'workbench.action.files.copyPathOfActiveFile'
40- sb . tooltip = 'Copy active file to clipboard' ;
40+ sb . command = 'workbench.action.files.copyPathOfActiveFile' ;
41+ if ( config . revealFile ) {
42+ sb . command = 'workbench.action.files.revealActiveFileInWindows' ;
43+ }
4144 return sb ;
4245}
4346
4447// this method is called when your extension is activated
4548// your extension is activated the very first time the command is executed
4649function activate ( context ) {
47-
48- sb = CreateStatusBar ( ) ;
49- vscode . window . onDidChangeActiveTextEditor ( OnStatusBarUpdate ) ;
50- OnStatusBarUpdate ( vscode . window . activeTextEditor ) ;
5150
52- context . subscriptions . push ( sb ) ;
51+ var config = vscode . workspace . getConfiguration ( 'ActiveFileInStatusBar' ) ;
52+ if ( config . enable ) {
53+ sb = CreateStatusBar ( ) ;
54+ vscode . window . onDidChangeActiveTextEditor ( OnStatusBarUpdate ) ;
55+ OnStatusBarUpdate ( vscode . window . activeTextEditor ) ;
56+
57+ context . subscriptions . push ( sb ) ;
58+ }
59+
5360}
5461exports . activate = activate ;
5562
0 commit comments