@@ -17,7 +17,7 @@ import { activateTaskProvider, runCommand } from './tasks';
17
17
18
18
import * as child_process from 'child_process' ;
19
19
import * as fs from 'fs' ;
20
- import path = require( 'path' ) ;
20
+ // import path = require('path');
21
21
22
22
import {
23
23
commands , ExtensionContext , IndentAction , languages , TextEditor ,
@@ -58,7 +58,7 @@ function didOpenTextDocument(document: TextDocument, context: ExtensionContext):
58
58
return ;
59
59
}
60
60
folder = getOuterMostWorkspaceFolder ( folder ) ;
61
- folder = getCargoTomlWorkspace ( folder , document . uri . fsPath ) ;
61
+ // folder = getCargoTomlWorkspace(folder, document.uri.fsPath);
62
62
if ( ! folder ) {
63
63
stopSpinner ( `RLS: Cargo.toml missing` ) ;
64
64
return ;
@@ -92,37 +92,37 @@ function sortedWorkspaceFolders(): string[] {
92
92
return _sortedWorkspaceFolders || [ ] ;
93
93
}
94
94
95
- function getCargoTomlWorkspace ( cur_workspace : WorkspaceFolder , file_path : string ) : WorkspaceFolder {
96
- if ( ! cur_workspace ) {
97
- return cur_workspace ;
98
- }
99
-
100
- const workspace_root = path . parse ( cur_workspace . uri . fsPath ) . dir ;
101
- const root_manifest = path . join ( workspace_root , 'Cargo.toml' ) ;
102
- if ( fs . existsSync ( root_manifest ) ) {
103
- return cur_workspace ;
104
- }
105
-
106
- let current = file_path ;
107
-
108
- while ( true ) {
109
- const old = current ;
110
- current = path . dirname ( current ) ;
111
- if ( old == current ) {
112
- break ;
113
- }
114
- if ( workspace_root == path . parse ( current ) . dir ) {
115
- break ;
116
- }
117
-
118
- const cargo_path = path . join ( current , 'Cargo.toml' ) ;
119
- if ( fs . existsSync ( cargo_path ) ) {
120
- return { ...cur_workspace , uri : Uri . parse ( current ) } ;
121
- }
122
- }
123
-
124
- return cur_workspace ;
125
- }
95
+ // function getCargoTomlWorkspace(cur_workspace: WorkspaceFolder, file_path: string): WorkspaceFolder {
96
+ // if (!cur_workspace) {
97
+ // return cur_workspace;
98
+ // }
99
+
100
+ // const workspace_root = path.parse(cur_workspace.uri.fsPath).dir;
101
+ // const root_manifest = path.join(workspace_root, 'Cargo.toml');
102
+ // if (fs.existsSync(root_manifest)) {
103
+ // return cur_workspace;
104
+ // }
105
+
106
+ // let current = file_path;
107
+
108
+ // while (true) {
109
+ // const old = current;
110
+ // current = path.dirname(current);
111
+ // if (old == current) {
112
+ // break;
113
+ // }
114
+ // if (workspace_root == path.parse(current).dir) {
115
+ // break;
116
+ // }
117
+
118
+ // const cargo_path = path.join(current, 'Cargo.toml');
119
+ // if (fs.existsSync(cargo_path)) {
120
+ // return { ...cur_workspace, uri: Uri.parse(current) };
121
+ // }
122
+ // }
123
+
124
+ // return cur_workspace;
125
+ // }
126
126
127
127
function getOuterMostWorkspaceFolder ( folder : WorkspaceFolder ) : WorkspaceFolder {
128
128
const sorted = sortedWorkspaceFolders ( ) ;
@@ -188,6 +188,7 @@ class ClientWorkspace {
188
188
}
189
189
190
190
async start ( context : ExtensionContext ) {
191
+ warnOnMissingCargoToml ( ) ;
191
192
192
193
startSpinner ( 'RLS' , 'Starting' ) ;
193
194
@@ -476,7 +477,15 @@ class ClientWorkspace {
476
477
}
477
478
}
478
479
480
+ async function warnOnMissingCargoToml ( ) {
481
+ const files = await workspace . findFiles ( 'Cargo.toml' ) ;
479
482
483
+ if ( files . length < 1 ) {
484
+ window . showWarningMessage (
485
+ 'A Cargo.toml file must be at the root of the workspace in order to support all features'
486
+ ) ;
487
+ }
488
+ }
480
489
481
490
function configureLanguage ( context : ExtensionContext ) {
482
491
const disposable = languages . setLanguageConfiguration ( 'rust' , {
0 commit comments