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

Commit a8b652a

Browse files
committed
apply pretty
1 parent 1e2e04c commit a8b652a

File tree

2 files changed

+53
-40
lines changed

2 files changed

+53
-40
lines changed

src/configuration.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ export class RLSConfiguration {
119119
}
120120

121121
public get multiProjectEnabled(): boolean {
122-
return this.configuration.get<boolean>('rust-client.enableMultiProjectSetup', false);
122+
return this.configuration.get<boolean>(
123+
'rust-client.enableMultiProjectSetup',
124+
false,
125+
);
123126
}
124127

125128
// Added ignoreChannel for readChannel function. Otherwise we end in an infinite loop.

src/extension.ts

+49-39
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,13 @@ function didOpenTextDocument(
9292
const folderPath = folder.uri.toString();
9393

9494
if (!workspaces.has(folderPath)) {
95-
9695
const workspace = new ClientWorkspace(folder);
9796
activeWorkspace = workspace;
9897
workspaces.set(folderPath, workspace);
9998
workspace.start(context);
10099
} else {
101100
const ws = workspaces.get(folderPath);
102-
activeWorkspace = typeof ws === "undefined" ? null : ws;
101+
activeWorkspace = typeof ws === 'undefined' ? null : ws;
103102
}
104103
}
105104

@@ -124,36 +123,39 @@ function sortedWorkspaceFolders(): string[] {
124123
return _sortedWorkspaceFolders || [];
125124
}
126125

127-
function getCargoTomlWorkspace(cur_workspace: WorkspaceFolder, file_path: string): WorkspaceFolder {
128-
if (!cur_workspace) {
129-
return cur_workspace;
130-
}
126+
function getCargoTomlWorkspace(
127+
curWorkspace: WorkspaceFolder,
128+
filePath: string,
129+
): WorkspaceFolder {
130+
if (!curWorkspace) {
131+
return curWorkspace;
132+
}
131133

132-
const workspace_root = path.parse(cur_workspace.uri.fsPath).dir;
133-
const root_manifest = path.join(workspace_root, 'Cargo.toml');
134-
if (fs.existsSync(root_manifest)) {
135-
return cur_workspace;
136-
}
134+
const workspaceRoot = path.parse(curWorkspace.uri.fsPath).dir;
135+
const rootManifest = path.join(workspaceRoot, 'Cargo.toml');
136+
if (fs.existsSync(rootManifest)) {
137+
return curWorkspace;
138+
}
137139

138-
let current = file_path;
140+
let current = filePath;
139141

140-
while (true) {
141-
const old = current;
142-
current = path.dirname(current);
143-
if (old == current) {
144-
break;
145-
}
146-
if (workspace_root == path.parse(current).dir) {
147-
break;
148-
}
142+
while (true) {
143+
const old = current;
144+
current = path.dirname(current);
145+
if (old === current) {
146+
break;
147+
}
148+
if (workspaceRoot === path.parse(current).dir) {
149+
break;
150+
}
149151

150-
const cargo_path = path.join(current, 'Cargo.toml');
151-
if (fs.existsSync(cargo_path)) {
152-
return { ...cur_workspace, uri: Uri.parse(current) };
153-
}
152+
const cargoPath = path.join(current, 'Cargo.toml');
153+
if (fs.existsSync(cargoPath)) {
154+
return { ...curWorkspace, uri: Uri.parse(current) };
154155
}
156+
}
155157

156-
return cur_workspace;
158+
return curWorkspace;
157159
}
158160

159161
function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder {
@@ -230,16 +232,19 @@ class ClientWorkspace {
230232
warnOnMissingCargoToml();
231233
}
232234

233-
234235
startSpinner('RLS', 'Starting');
235236

236237
const serverOptions: ServerOptions = async () => {
237238
await this.autoUpdate();
238239
return this.makeRlsProcess();
239240
};
240241

241-
const pattern = this.config.multiProjectEnabled ? `${this.folder.uri.path}/**` : undefined;
242-
const collectionName = this.config.multiProjectEnabled ? `rust ${this.folder.uri.toString()}` : 'rust';
242+
const pattern = this.config.multiProjectEnabled
243+
? `${this.folder.uri.path}/**`
244+
: undefined;
245+
const collectionName = this.config.multiProjectEnabled
246+
? `rust ${this.folder.uri.toString()}`
247+
: 'rust';
243248
const clientOptions: LanguageClientOptions = {
244249
// Register the server for Rust files
245250

@@ -283,7 +288,9 @@ class ClientWorkspace {
283288
clientOptions,
284289
);
285290

286-
const selector = this.config.multiProjectEnabled ? { language: 'rust', scheme: 'file', pattern } : { language: 'rust' };
291+
const selector = this.config.multiProjectEnabled
292+
? { language: 'rust', scheme: 'file', pattern }
293+
: { language: 'rust' };
287294

288295
this.setupProgressCounter();
289296
this.registerCommands(context, this.config.multiProjectEnabled);
@@ -308,7 +315,10 @@ class ClientWorkspace {
308315
commandsUnregistered = true;
309316
}
310317

311-
private registerCommands(context: ExtensionContext, multiProjectEnabled: boolean) {
318+
private registerCommands(
319+
context: ExtensionContext,
320+
multiProjectEnabled: boolean,
321+
) {
312322
if (!this.lc) {
313323
return;
314324
}
@@ -320,27 +330,27 @@ class ClientWorkspace {
320330
const rustupUpdateDisposable = commands.registerCommand(
321331
'rls.update',
322332
() => {
323-
const ws = multiProjectEnabled && activeWorkspace ? activeWorkspace : this;
333+
const ws =
334+
multiProjectEnabled && activeWorkspace ? activeWorkspace : this;
324335
return rustupUpdate(ws.config.rustupConfig());
325336
},
326337
);
327338
this.disposables.push(rustupUpdateDisposable);
328339

329340
const restartServer = commands.registerCommand('rls.restart', async () => {
330-
const ws = multiProjectEnabled && activeWorkspace ? activeWorkspace : this;
341+
const ws =
342+
multiProjectEnabled && activeWorkspace ? activeWorkspace : this;
331343
await ws.stop();
332344
return ws.start(context);
333-
334345
});
335346
this.disposables.push(restartServer);
336347

337348
this.disposables.push(
338349
commands.registerCommand('rls.run', (cmd: Execution) => {
339-
const ws = multiProjectEnabled && activeWorkspace ? activeWorkspace : this;
340-
runRlsCommand(ws.folder, cmd)
341-
},
342-
343-
),
350+
const ws =
351+
multiProjectEnabled && activeWorkspace ? activeWorkspace : this;
352+
runRlsCommand(ws.folder, cmd);
353+
}),
344354
);
345355
}
346356

0 commit comments

Comments
 (0)