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

Commit 47c66be

Browse files
committed
fix linting errors
1 parent da6bb20 commit 47c66be

File tree

2 files changed

+35
-42
lines changed

2 files changed

+35
-42
lines changed

src/extension.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import {
2121
ServerOptions,
2222
} from 'vscode-languageclient';
2323

24-
import * as workspace_util from './workspace_util';
2524
import { RLSConfiguration } from './configuration';
2625
import { SignatureHelpProvider } from './providers/signatureHelpProvider';
2726
import { checkForRls, ensureToolchain, rustupUpdate } from './rustup';
2827
import { startSpinner, stopSpinner } from './spinner';
2928
import { activateTaskProvider, Execution, runRlsCommand } from './tasks';
3029
import { withWsl } from './utils/child_process';
3130
import { uriWindowsToWsl, uriWslToWindows } from './utils/wslpath';
31+
import * as workspace_util from './workspace_util';
3232

3333
/**
3434
* Parameter type to `window/progress` request as issued by the RLS.
@@ -72,12 +72,12 @@ function whenOpeningTextDocument(
7272
}
7373

7474
const inMultiProjectMode = workspace
75-
.getConfiguration()
76-
.get<boolean>('rust-client.enableMultiProjectSetup', false);
75+
.getConfiguration()
76+
.get<boolean>('rust-client.enableMultiProjectSetup', false);
7777

7878
const inNestedOuterProjectMode = workspace
79-
.getConfiguration()
80-
.get<boolean>('rust-client.nestedMultiRootConfigInOutermost', true);
79+
.getConfiguration()
80+
.get<boolean>('rust-client.nestedMultiRootConfigInOutermost', true);
8181

8282
if (inMultiProjectMode) {
8383
folder = workspace_util.nearestParentWorkspace(folder, document.uri.fsPath);
@@ -125,7 +125,6 @@ function sortedWorkspaceFolders(): string[] {
125125
return _sortedWorkspaceFolders || [];
126126
}
127127

128-
129128
function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder {
130129
// TODO: decouple the global state such that it can be moved to workspace_util
131130
const sorted = sortedWorkspaceFolders();

src/workspace_util.ts

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,42 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
3-
import { WorkspaceFolder, Uri } from 'vscode';
4-
5-
3+
import { Uri, WorkspaceFolder } from 'vscode';
64

75
// searches up the folder structure until it finds a Cargo.toml
86
export function nearestParentWorkspace(
9-
curWorkspace: WorkspaceFolder,
10-
filePath: string,
11-
): WorkspaceFolder {
12-
13-
// check that the workspace folder already contains the "Cargo.toml"
14-
const workspaceRoot = path.parse(curWorkspace.uri.fsPath).dir;
15-
const rootManifest = path.join(workspaceRoot, 'Cargo.toml');
16-
if (fs.existsSync(rootManifest)) {
17-
return curWorkspace;
18-
}
19-
20-
// algorithm that will strip one folder at a time and check if that folder contains "Cargo.toml"
21-
let current = filePath;
22-
while (true) {
23-
const old = current;
24-
current = path.dirname(current);
25-
26-
// break in case there is a bug that could result in a busy loop
27-
if (old === current) {
28-
break;
29-
}
7+
curWorkspace: WorkspaceFolder,
8+
filePath: string,
9+
): WorkspaceFolder {
10+
// check that the workspace folder already contains the "Cargo.toml"
11+
const workspaceRoot = path.parse(curWorkspace.uri.fsPath).dir;
12+
const rootManifest = path.join(workspaceRoot, 'Cargo.toml');
13+
if (fs.existsSync(rootManifest)) {
14+
return curWorkspace;
15+
}
3016

31-
// break in case the strip folder has not changed
32-
if (workspaceRoot === path.parse(current).dir) {
33-
break;
34-
}
17+
// algorithm that will strip one folder at a time and check if that folder contains "Cargo.toml"
18+
let current = filePath;
19+
while (true) {
20+
const old = current;
21+
current = path.dirname(current);
3522

36-
// check if "Cargo.toml" is present in the parent folder
37-
const cargoPath = path.join(current, 'Cargo.toml');
38-
if (fs.existsSync(cargoPath)) {
23+
// break in case there is a bug that could result in a busy loop
24+
if (old === current) {
25+
break;
26+
}
3927

40-
// ghetto change the uri on Workspace folder to make vscode think it's located elsewhere
41-
return { ...curWorkspace, uri: Uri.parse(current) };
42-
}
28+
// break in case the strip folder has not changed
29+
if (workspaceRoot === path.parse(current).dir) {
30+
break;
4331
}
4432

45-
return curWorkspace;
33+
// check if "Cargo.toml" is present in the parent folder
34+
const cargoPath = path.join(current, 'Cargo.toml');
35+
if (fs.existsSync(cargoPath)) {
36+
// ghetto change the uri on Workspace folder to make vscode think it's located elsewhere
37+
return { ...curWorkspace, uri: Uri.parse(current) };
38+
}
4639
}
4740

48-
41+
return curWorkspace;
42+
}

0 commit comments

Comments
 (0)