|
5 | 5 | import*aspathfrom'path'; |
6 | 6 | import{ |
7 | 7 | TaskDefinition,Task,TaskGroup,ShellExecution,Uri,workspace, |
8 | | -TaskProvider,TaskScope,CustomExecution,ProcessExecution,TextEditor,Pseudoterminal,EventEmitter,Event,TerminalDimensions,window |
| 8 | +TaskProvider,TaskScope,CustomExecution,ProcessExecution,TextEditor,Pseudoterminal,EventEmitter,Event,TerminalDimensions,window,WorkspaceFolder |
9 | 9 | }from'vscode'; |
10 | 10 | import*asosfrom'os'; |
11 | 11 | import*asutilfrom'../common'; |
@@ -181,13 +181,18 @@ export class CppBuildTaskProvider implements TaskProvider { |
181 | 181 | }; |
182 | 182 | } |
183 | 183 |
|
184 | | -constactiveClient:Client=ext.getActiveClient(); |
185 | | -consturi:Uri|undefined=activeClient.RootUri; |
186 | | -if(!uri){ |
187 | | -thrownewError("No client URI found in getBuildTasks()"); |
188 | | -} |
189 | | -if(!workspace.getWorkspaceFolder(uri)){ |
190 | | -thrownewError("No target WorkspaceFolder found in getBuildTasks()"); |
| 184 | +consteditor:TextEditor|undefined=window.activeTextEditor; |
| 185 | +constfolder:WorkspaceFolder|undefined=editor ?workspace.getWorkspaceFolder(editor.document.uri) :undefined; |
| 186 | +// Check uri exists (single-mode files are ignored). |
| 187 | +if(folder){ |
| 188 | +constactiveClient:Client=ext.getActiveClient(); |
| 189 | +consturi:Uri|undefined=activeClient.RootUri; |
| 190 | +if(!uri){ |
| 191 | +thrownewError("No client URI found in getBuildTasks()"); |
| 192 | +} |
| 193 | +if(!workspace.getWorkspaceFolder(uri)){ |
| 194 | +thrownewError("No target WorkspaceFolder found in getBuildTasks()"); |
| 195 | +} |
191 | 196 | } |
192 | 197 |
|
193 | 198 | constscope:TaskScope=TaskScope.Workspace; |
|