Skip to content
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
7 changes: 4 additions & 3 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
handleError,
isClassDeployed,
isClassOrRtn,
isCompilable,
lastUsedLocalUri,
notIsfs,
notNull,
Expand Down Expand Up @@ -333,7 +334,7 @@ export async function importAndCompile(
throw error;
})
.then(() => {
if (compileFile) compile([file], flags);
if (compileFile && isCompilable(file.name)) compile([file], flags);
});
}

Expand Down Expand Up @@ -369,7 +370,7 @@ export async function compileOnly(askFlags = false, document?: vscode.TextDocume

const defaultFlags = config().compileFlags;
const flags = askFlags ? await compileFlags() : defaultFlags;
if (!file.fileName.startsWith("\\.vscode\\")) {
if (isCompilable(file.name)) {
compile([file], flags);
}
}
Expand Down Expand Up @@ -444,7 +445,7 @@ async function importFiles(files: vscode.Uri[], noCompile = false) {
)
.then((curFile) => {
if (curFile) {
if (typeof curFile.content == "string") toCompile.push(curFile); // Only compile text files
if (typeof curFile.content == "string" && isCompilable(curFile.name)) toCompile.push(curFile);
return importFile(curFile).then(() => outputChannel.appendLine("Imported file: " + curFile.fileName));
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/providers/FileSystemProvider/FileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
base64EncodeContent,
openLowCodeEditors,
compileErrorMsg,
isCompilable,
} from "../../utils";
import { FILESYSTEM_READONLY_SCHEMA, FILESYSTEM_SCHEMA, intLangId, macLangId } from "../../extension";
import { addIsfsFileToProject, modifyProject } from "../../commands/project";
Expand Down Expand Up @@ -578,7 +579,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
if (!entry) return; // entry is only empty when uri is open in a low-code editor
// Compile the document if required
if (
!uri.path.includes("/_vscode/") &&
isCompilable(entry.fileName) &&
vscode.workspace.getConfiguration("objectscript", uri).get("compileOnSave")
) {
// Need to return the compile promise because technically the post-save compilation
Expand Down
3 changes: 2 additions & 1 deletion src/utils/documentIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
openLowCodeEditors,
outputChannel,
displayableUri,
isCompilable,
} from ".";
import { isText } from "istextorbinary";
import { AtelierAPI } from "../api";
Expand Down Expand Up @@ -266,7 +267,7 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr
importFile(change.addedOrChanged)
.then(() => {
outputImport(change.addedOrChanged.name, uri);
if (conf.get("compileOnSave")) {
if (conf.get("compileOnSave") && isCompilable(change.addedOrChanged.name)) {
// Compile right away if this document is in the active text editor.
// This is needed to avoid noticeable latency when a user is editing
// a client-side file, saves it, and the auto-compile kicks in.
Expand Down
6 changes: 6 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,12 @@ export function displayableUri(uri: vscode.Uri): string {
return uri.scheme == "file" ? uri.fsPath : uri.toString(true);
}

/** Return `true` if document `name` can be compiled */
export function isCompilable(name: string): boolean {
// Exlcude web app files that are not CSP or CSR files
return !(name.includes("/") && !["csp", "csr"].includes(name.split(".").pop().toLowerCase()));
}

class Semaphore {
/** Queue of tasks waiting to acquire the semaphore */
private _tasks: (() => void)[] = [];
Expand Down