Skip to content

Commit 1acdf21

Browse files
committed
Small tweaks
1 parent fe9be08 commit 1acdf21

File tree

7 files changed

+100
-121
lines changed

7 files changed

+100
-121
lines changed

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@
105105
},
106106
{
107107
"command": "vscode-objectscript.compile",
108-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
108+
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
109109
},
110110
{
111111
"command": "vscode-objectscript.refreshLocalFile",
112-
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
112+
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
113113
},
114114
{
115115
"command": "vscode-objectscript.compileWithFlags",
116-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
116+
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
117117
},
118118
{
119119
"command": "vscode-objectscript.compileAll",
@@ -213,11 +213,11 @@
213213
},
214214
{
215215
"command": "vscode-objectscript.compileOnly",
216-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
216+
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
217217
},
218218
{
219219
"command": "vscode-objectscript.compileOnlyWithFlags",
220-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
220+
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
221221
},
222222
{
223223
"command": "vscode-objectscript.editOthers",
@@ -478,7 +478,7 @@
478478
},
479479
{
480480
"command": "vscode-objectscript.compile",
481-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
481+
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty",
482482
"group": "objectscript@3"
483483
},
484484
{
@@ -498,7 +498,7 @@
498498
},
499499
{
500500
"command": "vscode-objectscript.compileOnly",
501-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
501+
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty",
502502
"group": "objectscript@7"
503503
},
504504
{
@@ -545,7 +545,7 @@
545545
{
546546
"command": "vscode-objectscript.touchBar.compile",
547547
"group": "objectscript.compile",
548-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
548+
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
549549
},
550550
{
551551
"command": "vscode-objectscript.touchBar.viewOthers",
@@ -1183,7 +1183,7 @@
11831183
"command": "vscode-objectscript.compile",
11841184
"key": "Ctrl+F7",
11851185
"mac": "Cmd+F7",
1186-
"when": "editorLangId =~ /^objectscript/"
1186+
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/"
11871187
},
11881188
{
11891189
"command": "vscode-objectscript.compileAll",

src/commands/compile.ts

+11-27
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
fileSystemProvider,
1010
workspaceState,
1111
filesystemSchemas,
12+
schemas,
1213
} from "../extension";
1314
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
1415
import {
@@ -58,7 +59,7 @@ async function compileFlags(): Promise<string> {
5859
* @return mtime timestamp or -1.
5960
*/
6061
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)) {
6263
return -1;
6364
}
6465
const api = new AtelierAPI(file.uri);
@@ -93,6 +94,7 @@ export async function importFile(
9394
skipDeplCheck = false
9495
): Promise<any> {
9596
const api = new AtelierAPI(file.uri);
97+
if (!api.active) return;
9698
if (file.name.split(".").pop().toLowerCase() === "cls" && !skipDeplCheck) {
9799
if (await isClassDeployed(file.name, api)) {
98100
vscode.window.showErrorMessage(`Cannot import ${file.name} because it is deployed on the server.`, "Dismiss");
@@ -306,38 +308,19 @@ export async function importAndCompile(
306308
compileFile = true
307309
): Promise<any> {
308310
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
315313
return;
316314
}
317315

318316
const defaultFlags = config().compileFlags;
319317
const flags = askFlags ? await compileFlags() : defaultFlags;
320318
return importFile(file)
321319
.catch((error) => {
322-
// console.error(error);
323320
throw error;
324321
})
325322
.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);
341324
});
342325
}
343326

@@ -463,6 +446,7 @@ async function importFiles(files: vscode.Uri[], noCompile = false) {
463446
}
464447

465448
export async function importFolder(uri: vscode.Uri, noCompile = false): Promise<any> {
449+
if (filesystemSchemas.includes(uri.scheme)) return; // Not for server-side URIs
466450
if ((await vscode.workspace.fs.stat(uri)).type != vscode.FileType.Directory) {
467451
return importFiles([uri], noCompile);
468452
}
@@ -573,7 +557,7 @@ async function importFileFromContent(
573557
}
574558

575559
/** 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> {
577561
// This cast is safe because the only two callers intialize api with a workspace folder URI
578562
const conf = vscode.workspace.getConfiguration("objectscript", <vscode.Uri>api.wsOrFile);
579563
// Prompt the user for compilation
@@ -608,14 +592,14 @@ async function promptForCompile(imported: string[], api: AtelierAPI, refresh: bo
608592
})
609593
.catch(() => compileErrorMsg(conf))
610594
.finally(() => {
611-
if (refresh) {
595+
if (isIsfs) {
612596
// Refresh the files explorer to show the new files
613597
vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer");
614598
}
615599
})
616600
);
617601
} else {
618-
if (refresh) {
602+
if (isIsfs) {
619603
// Refresh the files explorer to show the new files
620604
vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer");
621605
}
@@ -867,7 +851,7 @@ export async function importXMLFiles(): Promise<any> {
867851
const docsToImport = await vscode.window.showQuickPick(quickPickItems, {
868852
canPickMany: true,
869853
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}'`,
871855
});
872856
if (docsToImport == undefined || docsToImport.length == 0) {
873857
return;

src/commands/studio.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from "vscode";
22
import { AtelierAPI } from "../api";
33
import { iscIcon } from "../extension";
4-
import { outputChannel, outputConsole, notIsfs, handleError, openCustomEditors } from "../utils";
4+
import { outputChannel, outputConsole, notIsfs, handleError, openLowCodeEditors } from "../utils";
55
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
66
import { UserAction } from "../api/atelier";
77
import { isfsDocumentName } from "../providers/FileSystemProvider/FileSystemProvider";
@@ -547,7 +547,7 @@ export async function fireOtherStudioAction(
547547
const studioActions = new StudioActions(uri);
548548
return (
549549
studioActions &&
550-
!openCustomEditors.includes(uri.toString()) && // The custom editor will handle all server-side source control interactions
550+
!openLowCodeEditors.has(uri.toString()) && // The low-code editor will handle all server-side source control interactions
551551
studioActions.fireOtherStudioAction(action, userAction)
552552
);
553553
}

0 commit comments

Comments
 (0)