From 3c6bc24ecea573f7edac94b6a784f168066bee1d Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 25 Sep 2025 08:49:23 -0400 Subject: [PATCH] Skip compilation of web app files that do not require it --- src/commands/compile.ts | 7 ++++--- src/providers/FileSystemProvider/FileSystemProvider.ts | 3 ++- src/utils/documentIndex.ts | 3 ++- src/utils/index.ts | 6 ++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/commands/compile.ts b/src/commands/compile.ts index b1893127..17e7e0f6 100644 --- a/src/commands/compile.ts +++ b/src/commands/compile.ts @@ -26,6 +26,7 @@ import { handleError, isClassDeployed, isClassOrRtn, + isCompilable, lastUsedLocalUri, notIsfs, notNull, @@ -333,7 +334,7 @@ export async function importAndCompile( throw error; }) .then(() => { - if (compileFile) compile([file], flags); + if (compileFile && isCompilable(file.name)) compile([file], flags); }); } @@ -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); } } @@ -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)); } }); diff --git a/src/providers/FileSystemProvider/FileSystemProvider.ts b/src/providers/FileSystemProvider/FileSystemProvider.ts index 3eec691d..f5b43d76 100644 --- a/src/providers/FileSystemProvider/FileSystemProvider.ts +++ b/src/providers/FileSystemProvider/FileSystemProvider.ts @@ -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"; @@ -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 diff --git a/src/utils/documentIndex.ts b/src/utils/documentIndex.ts index 770a7d4b..c610cb27 100644 --- a/src/utils/documentIndex.ts +++ b/src/utils/documentIndex.ts @@ -12,6 +12,7 @@ import { openLowCodeEditors, outputChannel, displayableUri, + isCompilable, } from "."; import { isText } from "istextorbinary"; import { AtelierAPI } from "../api"; @@ -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. diff --git a/src/utils/index.ts b/src/utils/index.ts index 210ab744..5862bc3f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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)[] = [];