diff --git a/basic-multi-root-sample/README.md b/basic-multi-root-sample/README.md index a0a85216..efe26315 100644 --- a/basic-multi-root-sample/README.md +++ b/basic-multi-root-sample/README.md @@ -6,6 +6,8 @@ This extension adds an entry to the status bar that shows the name of the curren - updates when there are changes to the number of `WorkspaceFolder` via the `workspace.onDidChangeWorkspaceFolders()` API - registers a setting `multiRootSample.statusColor` with a scope of `resource` to configure a color per `WorkspaceFolder` to use for the status bar item +![Show the folder of the active file](https://raw.githubusercontent.com/Microsoft/vscode-extension-samples/master/basic-multi-root-sample/preview.gif) + ## Running the example - Open this example in VS Code diff --git a/basic-multi-root-sample/preview.gif b/basic-multi-root-sample/preview.gif new file mode 100644 index 00000000..f2d72822 Binary files /dev/null and b/basic-multi-root-sample/preview.gif differ diff --git a/basic-multi-root-sample/src/extension.ts b/basic-multi-root-sample/src/extension.ts index b0f351f1..76b8209e 100644 --- a/basic-multi-root-sample/src/extension.ts +++ b/basic-multi-root-sample/src/extension.ts @@ -61,13 +61,13 @@ function getEditorInfo(): { text: string; tooltip: string; color: string; } { const folder = workspace.getWorkspaceFolder(resource); if (!folder) { text = `$(alert) → ${basename(resource.fsPath)}`; + } else { + text = `$(file-submodule) ${basename(folder.uri.fsPath)} → $(file-code) ${basename(resource.fsPath)}`; + tooltip = resource.fsPath; + + const multiRootConfigForResource = workspace.getConfiguration('multiRootSample', resource); + color = multiRootConfigForResource.get('statusColor'); } - - text = `$(file-submodule) ${basename(folder.uri.fsPath)} → $(file-code) ${basename(resource.fsPath)}`; - tooltip = resource.fsPath; - - const multiRootConfigForResource = workspace.getConfiguration('multiRootSample', resource); - color = multiRootConfigForResource.get('statusColor'); } return { text, tooltip, color };