Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Support VSCode workspaces #333

Merged
merged 3 commits into from
Jun 12, 2018
Merged

Support VSCode workspaces #333

merged 3 commits into from
Jun 12, 2018

Conversation

nrc
Copy link
Member

@nrc nrc commented Jun 6, 2018

Copy link
Member

@Xanewok Xanewok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! It took some time to initially understand the changes (left some comments) but that might be just me coming back after a break.

This feature looks like something that might finally push us to later dig into VSCode testing and hopefully test some of the related functionality, if it's possible!

if (workspaces.has(folder.uri.toString())) {
continue;
}
for (const f of fs.readdirSync(folder.uri.fsPath)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this checks if the added workspace, which is not contained in one of the existing workspace folders, contains a Cargo.toml file to decide whether to run the server - maybe we more idiomatic would be to use the newly added workspace.findFiles with RelativePattern to determine whether it contains a Cargo.toml file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works unfortunately, because at this point we're checking whether we should create a workspace and to use RelativePattern you need a workspace already created.

src/extension.ts Outdated
// We run one RLS and one corresponding language client per workspace folder
// (VSCode workspace, not Cargo workspace). This class contains all the per-client
// and per-workspace stuff.
class Workspace {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a while to understand what is referred to by workspace(s) until I got to the definition here - I know naming is hard and this might be too generic, but maybe something along the lines of ServerFolderContext might be better? Also the workspace namespace refers to the single VSCode workspace that consists of folders, so having multiple Workspaces coupled with VSCode workspace folders seems somewhat confusing here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah, agree Workspace is a bit hard to understand. I've gone for ClientWorkspace I don't think it is much better, but I think it is important to note that this is about the language client, rather than the server and about vscode workspaces.

}

let lc: LanguageClient;
function didChangeWorkspaceFolders(e: WorkspaceFoldersChangeEvent, context: ExtensionContext): void {
_sortedWorkspaceFolders = undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: I think it'd be good to highlight the fact that getOuterMostWorkspaceFolder caches the result and reuses it; at a glance it's hard to spot that calling the function reuses a global cache here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nrc
Copy link
Member Author

nrc commented Jun 12, 2018

Thanks for the review!

@nrc nrc merged commit 735d73e into master Jun 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants