@@ -121,59 +121,54 @@ export async function createClient(
121
121
const preview = config . previewRustcOutput ;
122
122
const errorCode = config . useRustcErrorCode ;
123
123
diagnosticList . forEach ( ( diag , idx ) => {
124
- let value =
124
+ const value =
125
125
typeof diag . code === "string" || typeof diag . code === "number"
126
126
? diag . code
127
127
: diag . code ?. value ;
128
128
if ( value === "unlinked-file" && ! unlinkedFiles . includes ( uri ) ) {
129
- let config = vscode . workspace . getConfiguration ( "rust-analyzer" ) ;
129
+ const config = vscode . workspace . getConfiguration ( "rust-analyzer" ) ;
130
130
if ( config . get ( "showUnlinkedFileNotification" ) ) {
131
131
unlinkedFiles . push ( uri ) ;
132
- let folder = vscode . workspace . getWorkspaceFolder ( uri ) ?. uri . fsPath ;
132
+ const folder = vscode . workspace . getWorkspaceFolder ( uri ) ?. uri . fsPath ;
133
133
if ( folder ) {
134
- let parent_backslash = uri . fsPath . lastIndexOf (
134
+ const parentBackslash = uri . fsPath . lastIndexOf (
135
135
pathSeparator + "src"
136
136
) ;
137
- let parent = uri . fsPath . substring ( 0 , parent_backslash ) ;
137
+ const parent = uri . fsPath . substring ( 0 , parentBackslash ) ;
138
138
139
139
if ( parent . startsWith ( folder ) ) {
140
- let path = vscode . Uri . file (
140
+ const path = vscode . Uri . file (
141
141
parent + pathSeparator + "Cargo.toml"
142
142
) ;
143
- void vscode . workspace . fs . stat ( path ) . then ( ( ) => {
144
- vscode . window
145
- . showInformationMessage (
146
- `This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at ${ path } , do you want to add it to the linked Projects?` ,
147
- "Yes" ,
148
- "No" ,
149
- "Don't show this again"
150
- )
151
- . then ( ( choice ) => {
152
- switch ( choice ) {
153
- case "Yes" :
154
- break ;
155
- case "No" :
156
- config . update (
157
- "linkedProjects" ,
158
- config
159
- . get < any [ ] > ( "linkedProjects" )
160
- ?. concat (
161
- path . fsPath . substring (
162
- folder ! . length
163
- )
164
- ) ,
165
- false
166
- ) ;
167
- break ;
168
- case "Don't show this again" :
169
- config . update (
170
- "showUnlinkedFileNotification" ,
171
- false ,
172
- false
173
- ) ;
174
- break ;
175
- }
176
- } ) ;
143
+ void vscode . workspace . fs . stat ( path ) . then ( async ( ) => {
144
+ const choice = await vscode . window . showInformationMessage (
145
+ `This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at ${ path } , do you want to add it to the linked Projects?` ,
146
+ "Yes" ,
147
+ "No" ,
148
+ "Don't show this again"
149
+ ) ;
150
+ switch ( choice ) {
151
+ case "Yes" :
152
+ break ;
153
+ case "No" :
154
+ await config . update (
155
+ "linkedProjects" ,
156
+ config
157
+ . get < any [ ] > ( "linkedProjects" )
158
+ ?. concat (
159
+ path . fsPath . substring ( folder . length )
160
+ ) ,
161
+ false
162
+ ) ;
163
+ break ;
164
+ case "Don't show this again" :
165
+ await config . update (
166
+ "showUnlinkedFileNotification" ,
167
+ false ,
168
+ false
169
+ ) ;
170
+ break ;
171
+ }
177
172
} ) ;
178
173
}
179
174
}
0 commit comments