Skip to content

Small tweaks #1544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@
},
{
"command": "vscode-objectscript.compile",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
},
{
"command": "vscode-objectscript.refreshLocalFile",
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
},
{
"command": "vscode-objectscript.compileWithFlags",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
},
{
"command": "vscode-objectscript.compileAll",
Expand Down Expand Up @@ -213,11 +213,11 @@
},
{
"command": "vscode-objectscript.compileOnly",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
},
{
"command": "vscode-objectscript.compileOnlyWithFlags",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
},
{
"command": "vscode-objectscript.editOthers",
Expand Down Expand Up @@ -478,7 +478,7 @@
},
{
"command": "vscode-objectscript.compile",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty",
"group": "objectscript@3"
},
{
Expand All @@ -498,7 +498,7 @@
},
{
"command": "vscode-objectscript.compileOnly",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty",
"group": "objectscript@7"
},
{
Expand Down Expand Up @@ -545,7 +545,7 @@
{
"command": "vscode-objectscript.touchBar.compile",
"group": "objectscript.compile",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
},
{
"command": "vscode-objectscript.touchBar.viewOthers",
Expand Down Expand Up @@ -1183,7 +1183,7 @@
"command": "vscode-objectscript.compile",
"key": "Ctrl+F7",
"mac": "Cmd+F7",
"when": "editorLangId =~ /^objectscript/"
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/"
},
{
"command": "vscode-objectscript.compileAll",
Expand Down
38 changes: 11 additions & 27 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
fileSystemProvider,
workspaceState,
filesystemSchemas,
schemas,
} from "../extension";
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
import {
Expand Down Expand Up @@ -58,7 +59,7 @@ async function compileFlags(): Promise<string> {
* @return mtime timestamp or -1.
*/
export async function checkChangedOnServer(file: CurrentTextFile | CurrentBinaryFile, force = false): Promise<number> {
if (!file || !file.uri) {
if (!file || !file.uri || schemas.includes(file.uri.scheme)) {
return -1;
}
const api = new AtelierAPI(file.uri);
Expand Down Expand Up @@ -93,6 +94,7 @@ export async function importFile(
skipDeplCheck = false
): Promise<any> {
const api = new AtelierAPI(file.uri);
if (!api.active) return;
if (file.name.split(".").pop().toLowerCase() === "cls" && !skipDeplCheck) {
if (await isClassDeployed(file.name, api)) {
vscode.window.showErrorMessage(`Cannot import ${file.name} because it is deployed on the server.`, "Dismiss");
Expand Down Expand Up @@ -306,38 +308,19 @@ export async function importAndCompile(
compileFile = true
): Promise<any> {
const file = currentFile(document);
if (!file) {
return;
}

// Do nothing if it is a local file and objectscript.conn.active is false
if (notIsfs(file.uri) && !config("conn").active) {
if (!file || filesystemSchemas.includes(file.uri.scheme) || !new AtelierAPI(file.uri).active) {
// Not for server-side URIs or folders with inactive server connections
return;
}

const defaultFlags = config().compileFlags;
const flags = askFlags ? await compileFlags() : defaultFlags;
return importFile(file)
.catch((error) => {
// console.error(error);
throw error;
})
.then(() => {
if (!file.fileName.startsWith("\\.vscode\\")) {
if (compileFile) {
compile([file], flags);
} else {
if (filesystemSchemas.includes(file.uri.scheme)) {
// Fire the file changed event to avoid VSCode alerting the user on the next save that
// "The content of the file is newer."
fileSystemProvider.fireFileChanged(file.uri);
}
}
} else if (filesystemSchemas.includes(file.uri.scheme)) {
// Fire the file changed event to avoid VSCode alerting the user on the next folder-specific save (e.g. of settings.json) that
// "The content of the file is newer."
fileSystemProvider.fireFileChanged(file.unredirectedUri ?? file.uri);
}
if (compileFile) compile([file], flags);
});
}

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

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

/** Prompt the user to compile documents after importing them */
async function promptForCompile(imported: string[], api: AtelierAPI, refresh: boolean): Promise<void> {
async function promptForCompile(imported: string[], api: AtelierAPI, isIsfs: boolean): Promise<void> {
// This cast is safe because the only two callers intialize api with a workspace folder URI
const conf = vscode.workspace.getConfiguration("objectscript", <vscode.Uri>api.wsOrFile);
// Prompt the user for compilation
Expand Down Expand Up @@ -608,14 +592,14 @@ async function promptForCompile(imported: string[], api: AtelierAPI, refresh: bo
})
.catch(() => compileErrorMsg(conf))
.finally(() => {
if (refresh) {
if (isIsfs) {
// Refresh the files explorer to show the new files
vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer");
}
})
);
} else {
if (refresh) {
if (isIsfs) {
// Refresh the files explorer to show the new files
vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer");
}
Expand Down Expand Up @@ -867,7 +851,7 @@ export async function importXMLFiles(): Promise<any> {
const docsToImport = await vscode.window.showQuickPick(quickPickItems, {
canPickMany: true,
ignoreFocusOut: true,
title: `Select the documents to import into namespace '${api.ns.toUpperCase()}' on server '${api.serverId}'`,
title: `Select the documents to import into namespace '${api.ns}' on server '${api.serverId}'`,
});
if (docsToImport == undefined || docsToImport.length == 0) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/commands/studio.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from "vscode";
import { AtelierAPI } from "../api";
import { iscIcon } from "../extension";
import { outputChannel, outputConsole, notIsfs, handleError, openCustomEditors } from "../utils";
import { outputChannel, outputConsole, notIsfs, handleError, openLowCodeEditors } from "../utils";
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
import { UserAction } from "../api/atelier";
import { isfsDocumentName } from "../providers/FileSystemProvider/FileSystemProvider";
Expand Down Expand Up @@ -547,7 +547,7 @@ export async function fireOtherStudioAction(
const studioActions = new StudioActions(uri);
return (
studioActions &&
!openCustomEditors.includes(uri.toString()) && // The custom editor will handle all server-side source control interactions
!openLowCodeEditors.has(uri.toString()) && // The low-code editor will handle all server-side source control interactions
studioActions.fireOtherStudioAction(action, userAction)
);
}
Loading