Skip to content

Commit

Permalink
updated multi-root support with a more native impl
Browse files Browse the repository at this point in the history
  • Loading branch information
lonhutt committed Oct 24, 2024
1 parent be4c6d4 commit 1c11074
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 125 deletions.
74 changes: 40 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,6 @@
{
"id": "bazelTaskOutline",
"name": "Bazel Run Targets"
},
{
"id": "rootFileViewer",
"name": "Project Root (Files)",
"when": "isMultiRoot"
}
]
},
Expand Down Expand Up @@ -333,7 +328,7 @@
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vscode/test-electron": "^2.3.4",
"@vscode/vsce": "^3.0.0",
"@vscode/vsce": "^3.2.1",
"esbuild": "0.19.8",
"esbuild-plugin-eslint": "^0.3.7",
"esbuild-visualizer": "^0.4.1",
Expand Down
5 changes: 0 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { registerLSClient } from './loggingTCPServer';
import { ProjectViewManager } from './projectViewManager';
import { BazelRunTargetProvider } from './provider/bazelRunTargetProvider';
import { BazelTaskProvider } from './provider/bazelTaskProvider';
import { RootFileViewProvider } from './provider/rootFileViewProvider';
import {
getWorkspaceRoot,
initBazelProjectFile,
Expand All @@ -46,10 +45,6 @@ export async function activate(context: ExtensionContext) {
BazelRunTargetProvider.instance
);
tasks.registerTaskProvider('bazel', new BazelTaskProvider());
window.registerTreeDataProvider(
'rootFileViewer',
RootFileViewProvider.instance
);

BazelLanguageServerTerminal.trace('extension activated');

Expand Down
16 changes: 12 additions & 4 deletions src/projectViewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@ export namespace ProjectViewManager {
extensions: await getVscodeConfig('extensions'),
};
writeFileSync(
`${workspaceRoot}/${workspaceRootName}.code-workspace`,
`${workspaceRoot}/workspace.code-workspace`,
Buffer.from(JSON.stringify(workspaceFile, null, 2))
);

// cleanup all old single root workspace files
await workspace.fs.delete(Uri.file(`${workspaceRoot}/.vscode`), {
recursive: true,
});

// reload the window using the new workspace
commands.executeCommand(
'vscode.openFolder',
Uri.file(`${workspaceRoot}/${workspaceRootName}.code-workspace`)
Uri.file(`${workspaceRoot}/workspace.code-workspace`)
);
}
return;
Expand Down Expand Up @@ -77,6 +82,9 @@ export namespace ProjectViewManager {

async function getDisplayFolders(): Promise<string[]> {
let displayFolders = new Set<string>(['.eclipse']); // TODO bubble this out to a setting
if (isMultiRoot()) {
displayFolders.add('.');
}
try {
const bazelProjectFile = await getBazelProjectFile();
if (bazelProjectFile.directories.includes('.')) {
Expand Down Expand Up @@ -164,11 +172,11 @@ export namespace ProjectViewManager {
k.includes('.eclipse')
).length;

const viewAll = displayFolders.includes('.');
const viewAll = displayFolders.includes('.') && !isMultiRoot();

const fileWatcherExcludePattern = viewAll
? ''
: `**/!(${Array.from(displayFolders.sort()).join('|')})/**`;
: `**/!(${Array.from(displayFolders.filter((s) => s !== '.').sort()).join('|')})/**`;

if (viewAll) {
// if viewAll and existing config doesn't contain .eclipse return
Expand Down
76 changes: 0 additions & 76 deletions src/provider/rootFileViewProvider.ts

This file was deleted.

0 comments on commit 1c11074

Please sign in to comment.