|
9 | 9 | fileSystemProvider,
|
10 | 10 | workspaceState,
|
11 | 11 | filesystemSchemas,
|
| 12 | + schemas, |
12 | 13 | } from "../extension";
|
13 | 14 | import { DocumentContentProvider } from "../providers/DocumentContentProvider";
|
14 | 15 | import {
|
@@ -58,7 +59,7 @@ async function compileFlags(): Promise<string> {
|
58 | 59 | * @return mtime timestamp or -1.
|
59 | 60 | */
|
60 | 61 | export async function checkChangedOnServer(file: CurrentTextFile | CurrentBinaryFile, force = false): Promise<number> {
|
61 |
| - if (!file || !file.uri) { |
| 62 | + if (!file || !file.uri || schemas.includes(file.uri.scheme)) { |
62 | 63 | return -1;
|
63 | 64 | }
|
64 | 65 | const api = new AtelierAPI(file.uri);
|
@@ -93,6 +94,7 @@ export async function importFile(
|
93 | 94 | skipDeplCheck = false
|
94 | 95 | ): Promise<any> {
|
95 | 96 | const api = new AtelierAPI(file.uri);
|
| 97 | + if (!api.active) return; |
96 | 98 | if (file.name.split(".").pop().toLowerCase() === "cls" && !skipDeplCheck) {
|
97 | 99 | if (await isClassDeployed(file.name, api)) {
|
98 | 100 | vscode.window.showErrorMessage(`Cannot import ${file.name} because it is deployed on the server.`, "Dismiss");
|
@@ -306,38 +308,19 @@ export async function importAndCompile(
|
306 | 308 | compileFile = true
|
307 | 309 | ): Promise<any> {
|
308 | 310 | const file = currentFile(document);
|
309 |
| - if (!file) { |
310 |
| - return; |
311 |
| - } |
312 |
| - |
313 |
| - // Do nothing if it is a local file and objectscript.conn.active is false |
314 |
| - if (notIsfs(file.uri) && !config("conn").active) { |
| 311 | + if (!file || filesystemSchemas.includes(file.uri.scheme) || !new AtelierAPI(file.uri).active) { |
| 312 | + // Not for server-side URIs or folders with inactive server connections |
315 | 313 | return;
|
316 | 314 | }
|
317 | 315 |
|
318 | 316 | const defaultFlags = config().compileFlags;
|
319 | 317 | const flags = askFlags ? await compileFlags() : defaultFlags;
|
320 | 318 | return importFile(file)
|
321 | 319 | .catch((error) => {
|
322 |
| - // console.error(error); |
323 | 320 | throw error;
|
324 | 321 | })
|
325 | 322 | .then(() => {
|
326 |
| - if (!file.fileName.startsWith("\\.vscode\\")) { |
327 |
| - if (compileFile) { |
328 |
| - compile([file], flags); |
329 |
| - } else { |
330 |
| - if (filesystemSchemas.includes(file.uri.scheme)) { |
331 |
| - // Fire the file changed event to avoid VSCode alerting the user on the next save that |
332 |
| - // "The content of the file is newer." |
333 |
| - fileSystemProvider.fireFileChanged(file.uri); |
334 |
| - } |
335 |
| - } |
336 |
| - } else if (filesystemSchemas.includes(file.uri.scheme)) { |
337 |
| - // Fire the file changed event to avoid VSCode alerting the user on the next folder-specific save (e.g. of settings.json) that |
338 |
| - // "The content of the file is newer." |
339 |
| - fileSystemProvider.fireFileChanged(file.unredirectedUri ?? file.uri); |
340 |
| - } |
| 323 | + if (compileFile) compile([file], flags); |
341 | 324 | });
|
342 | 325 | }
|
343 | 326 |
|
@@ -463,6 +446,7 @@ async function importFiles(files: vscode.Uri[], noCompile = false) {
|
463 | 446 | }
|
464 | 447 |
|
465 | 448 | export async function importFolder(uri: vscode.Uri, noCompile = false): Promise<any> {
|
| 449 | + if (filesystemSchemas.includes(uri.scheme)) return; // Not for server-side URIs |
466 | 450 | if ((await vscode.workspace.fs.stat(uri)).type != vscode.FileType.Directory) {
|
467 | 451 | return importFiles([uri], noCompile);
|
468 | 452 | }
|
@@ -573,7 +557,7 @@ async function importFileFromContent(
|
573 | 557 | }
|
574 | 558 |
|
575 | 559 | /** Prompt the user to compile documents after importing them */
|
576 |
| -async function promptForCompile(imported: string[], api: AtelierAPI, refresh: boolean): Promise<void> { |
| 560 | +async function promptForCompile(imported: string[], api: AtelierAPI, isIsfs: boolean): Promise<void> { |
577 | 561 | // This cast is safe because the only two callers intialize api with a workspace folder URI
|
578 | 562 | const conf = vscode.workspace.getConfiguration("objectscript", <vscode.Uri>api.wsOrFile);
|
579 | 563 | // Prompt the user for compilation
|
@@ -608,14 +592,14 @@ async function promptForCompile(imported: string[], api: AtelierAPI, refresh: bo
|
608 | 592 | })
|
609 | 593 | .catch(() => compileErrorMsg(conf))
|
610 | 594 | .finally(() => {
|
611 |
| - if (refresh) { |
| 595 | + if (isIsfs) { |
612 | 596 | // Refresh the files explorer to show the new files
|
613 | 597 | vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer");
|
614 | 598 | }
|
615 | 599 | })
|
616 | 600 | );
|
617 | 601 | } else {
|
618 |
| - if (refresh) { |
| 602 | + if (isIsfs) { |
619 | 603 | // Refresh the files explorer to show the new files
|
620 | 604 | vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer");
|
621 | 605 | }
|
@@ -867,7 +851,7 @@ export async function importXMLFiles(): Promise<any> {
|
867 | 851 | const docsToImport = await vscode.window.showQuickPick(quickPickItems, {
|
868 | 852 | canPickMany: true,
|
869 | 853 | ignoreFocusOut: true,
|
870 |
| - title: `Select the documents to import into namespace '${api.ns.toUpperCase()}' on server '${api.serverId}'`, |
| 854 | + title: `Select the documents to import into namespace '${api.ns}' on server '${api.serverId}'`, |
871 | 855 | });
|
872 | 856 | if (docsToImport == undefined || docsToImport.length == 0) {
|
873 | 857 | return;
|
|
0 commit comments