Skip to content

Commit 8fca3df

Browse files
committed
Add configuration option to turn off post-save compile
1 parent 6d2899b commit 8fca3df

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,11 @@
913913
"description": "Automatically show terminal when connected to docker-compose.",
914914
"type": "boolean",
915915
"default": false
916+
},
917+
"objectscript.compileOnSave": {
918+
"description": "Automatically compile an InterSystems file when saved in the editor.",
919+
"type": "boolean",
920+
"default": true
916921
}
917922
}
918923
},

src/commands/compile.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
240240
.then(loadChanges);
241241
}
242242

243-
export async function importAndCompile(askFlags = false, document?: vscode.TextDocument): Promise<any> {
243+
export async function importAndCompile(
244+
askFlags = false,
245+
document?: vscode.TextDocument,
246+
compileFile = true
247+
): Promise<any> {
244248
const file = currentFile(document);
245249
if (!file) {
246250
return;
@@ -260,7 +264,15 @@ export async function importAndCompile(askFlags = false, document?: vscode.TextD
260264
})
261265
.then(() => {
262266
if (!file.fileName.startsWith("\\.vscode\\")) {
263-
compile([file], flags);
267+
if (compileFile) {
268+
compile([file], flags);
269+
} else {
270+
if (file.uri.scheme === FILESYSTEM_SCHEMA || file.uri.scheme === FILESYSTEM_READONLY_SCHEMA) {
271+
// Fire the file changed event to avoid VSCode alerting the user on the next save that
272+
// "The content of the file is newer."
273+
fileSystemProvider.fireFileChanged(file.uri);
274+
}
275+
}
264276
}
265277
});
266278
}

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
534534
workspace.onDidSaveTextDocument((file) => {
535535
if (schemas.includes(file.uri.scheme) || languages.includes(file.languageId)) {
536536
if (documentBeingProcessed !== file) {
537-
return importAndCompile(false, file);
537+
return importAndCompile(false, file, config("compileOnSave"));
538538
}
539539
}
540540
});

0 commit comments

Comments
 (0)