Skip to content

Commit 1ff8cd9

Browse files
committed
Added icons, allow reveal in OS
1 parent 737ffd3 commit 1ff8cd9

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

extension.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ var i = 0;
55
var sb = null;
66

77
function 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

1610
function 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

3535
function 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
4649
function 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
}
5461
exports.activate = activate;
5562

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"default": true,
3434
"description": "Show fullpath or relative path in status bar."
3535
},
36-
"ActiveFileInStatusBar.showInFileExplorer": {
36+
"ActiveFileInStatusBar.revealFile": {
3737
"type": "boolean",
3838
"default": false,
39-
"description": "On click of the statusbar item show file in the file system explorer."
39+
"description": "Reveal the active file in the file system."
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)