Skip to content

Commit

Permalink
Revert Cargo.toml changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Dec 8, 2018
1 parent c6996c5 commit da3697e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Unreleased

### 0.5.3 - 2018-12-08

* Revert Cargo.toml changes

### 0.5.2 - 2018-12-07

* Prefer workspace Cargo.toml to local ones
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rust",
"displayName": "Rust (rls)",
"description": "Rust language support - code completion, Intellisense, refactoring, reformatting, errors, snippets. A client for the Rust Language Server, built by the RLS team.",
"version": "0.5.2",
"version": "0.5.3",
"publisher": "rust-lang",
"icon": "rust-icon.png",
"galleryBanner": {
Expand Down
75 changes: 42 additions & 33 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { activateTaskProvider, runCommand } from './tasks';

import * as child_process from 'child_process';
import * as fs from 'fs';
import path = require('path');
//import path = require('path');

import {
commands, ExtensionContext, IndentAction, languages, TextEditor,
Expand Down Expand Up @@ -58,7 +58,7 @@ function didOpenTextDocument(document: TextDocument, context: ExtensionContext):
return;
}
folder = getOuterMostWorkspaceFolder(folder);
folder = getCargoTomlWorkspace(folder, document.uri.fsPath);
// folder = getCargoTomlWorkspace(folder, document.uri.fsPath);
if (!folder) {
stopSpinner(`RLS: Cargo.toml missing`);
return;
Expand Down Expand Up @@ -92,37 +92,37 @@ function sortedWorkspaceFolders(): string[] {
return _sortedWorkspaceFolders || [];
}

function getCargoTomlWorkspace(cur_workspace: WorkspaceFolder, file_path: string): WorkspaceFolder {
if (!cur_workspace) {
return cur_workspace;
}

const workspace_root = path.parse(cur_workspace.uri.fsPath).dir;
const root_manifest = path.join(workspace_root, 'Cargo.toml');
if (fs.existsSync(root_manifest)) {
return cur_workspace;
}

let current = file_path;

while (true) {
const old = current;
current = path.dirname(current);
if (old == current) {
break;
}
if (workspace_root == path.parse(current).dir) {
break;
}

const cargo_path = path.join(current, 'Cargo.toml');
if (fs.existsSync(cargo_path)) {
return { ...cur_workspace, uri: Uri.parse(current) };
}
}

return cur_workspace;
}
// function getCargoTomlWorkspace(cur_workspace: WorkspaceFolder, file_path: string): WorkspaceFolder {
// if (!cur_workspace) {
// return cur_workspace;
// }

// const workspace_root = path.parse(cur_workspace.uri.fsPath).dir;
// const root_manifest = path.join(workspace_root, 'Cargo.toml');
// if (fs.existsSync(root_manifest)) {
// return cur_workspace;
// }

// let current = file_path;

// while (true) {
// const old = current;
// current = path.dirname(current);
// if (old == current) {
// break;
// }
// if (workspace_root == path.parse(current).dir) {
// break;
// }

// const cargo_path = path.join(current, 'Cargo.toml');
// if (fs.existsSync(cargo_path)) {
// return { ...cur_workspace, uri: Uri.parse(current) };
// }
// }

// return cur_workspace;
// }

function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder {
const sorted = sortedWorkspaceFolders();
Expand Down Expand Up @@ -188,6 +188,7 @@ class ClientWorkspace {
}

async start(context: ExtensionContext) {
warnOnMissingCargoToml();

startSpinner('RLS', 'Starting');

Expand Down Expand Up @@ -476,7 +477,15 @@ class ClientWorkspace {
}
}

async function warnOnMissingCargoToml() {
const files = await workspace.findFiles('Cargo.toml');

if (files.length < 1) {
window.showWarningMessage(
'A Cargo.toml file must be at the root of the workspace in order to support all features'
);
}
}

function configureLanguage(context: ExtensionContext) {
const disposable = languages.setLanguageConfiguration('rust', {
Expand Down

0 comments on commit da3697e

Please sign in to comment.