From 5b4c18a68b9851044f10ce62ef6e9ed434dff6dd Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Tue, 3 Jun 2025 08:43:58 -0400 Subject: [PATCH 1/2] More client-side tweaks --- src/extension.ts | 6 ++++-- src/utils/documentIndex.ts | 29 +++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 17fc4171..39ddb153 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -106,6 +106,7 @@ import { isClassOrRtn, addWsServerRootFolderData, getWsFolder, + exportedUris, } from "./utils"; import { ObjectScriptDiagnosticProvider } from "./providers/ObjectScriptDiagnosticProvider"; import { DocumentLinkProvider } from "./providers/DocumentLinkProvider"; @@ -1253,8 +1254,9 @@ export async function activate(context: vscode.ExtensionContext): Promise { vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) => { return Promise.all( e.files - .filter(notIsfs) - .filter(isClassOrRtn) + // Only attempt to adjust the names of classes and routines that are + // not server-side files and were not created due to an export + .filter((f) => notIsfs(f) && isClassOrRtn(f) && !exportedUris.has(f.toString())) .map(async (uri) => { // Determine the file name const workspace = workspaceFolderOfUri(uri); diff --git a/src/utils/documentIndex.ts b/src/utils/documentIndex.ts index 66b87ba3..595cc3a6 100644 --- a/src/utils/documentIndex.ts +++ b/src/utils/documentIndex.ts @@ -86,20 +86,11 @@ function generateCompileFn(): (doc: CurrentTextFile | CurrentBinaryFile) => void // Clear the previous timeout to reset the debounce timer clearTimeout(timeout); - // Compile right away if this document is in the active text editor - // and there are no other documents in the queue. This is needed - // to avoid noticeable latency when a user is editing a client-side - // file, saves it, and the auto-compile kicks in. - if (docs.length == 1 && vscode.window.activeTextEditor?.document.uri.toString() == doc.uri.toString()) { - compile([...docs]); - docs.length = 0; - return; - } - // Set a new timeout to call the function after the specified delay timeout = setTimeout(() => { - compile([...docs]); + const docsCopy = [...docs]; docs.length = 0; + compile(docsCopy); }, debounceDelay); }; } @@ -118,7 +109,9 @@ function generateDeleteFn(wsFolderUri: vscode.Uri): (doc: string) => void { // Set a new timeout to call the function after the specified delay timeout = setTimeout(() => { - api.deleteDocs([...docs]).then((data) => { + const docsCopy = [...docs]; + docs.length = 0; + api.deleteDocs(docsCopy).then((data) => { let failed = 0; for (const doc of data.result) { if (doc.status != "" && !doc.status.includes("#16005:")) { @@ -142,7 +135,6 @@ function generateDeleteFn(wsFolderUri: vscode.Uri): (doc: string) => void { ); } }); - docs.length = 0; }, debounceDelay); }; } @@ -241,7 +233,16 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr // Create or update the document on the server importFile(change.addedOrChanged) .then(() => { - if (conf.get("compileOnSave")) debouncedCompile(change.addedOrChanged); + if (conf.get("compileOnSave")) { + // 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. + if (vscode.window.activeTextEditor?.document.uri.toString() == uriString) { + compile([change.addedOrChanged]); + } else { + debouncedCompile(change.addedOrChanged); + } + } }) // importFile handles any server errors .catch(() => {}); From 60d73285321645c8f50a10d649b13d979b00ba6d Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 5 Jun 2025 09:06:28 -0400 Subject: [PATCH 2/2] Changes from user feedback --- src/utils/documentIndex.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/documentIndex.ts b/src/utils/documentIndex.ts index 595cc3a6..344bc4b1 100644 --- a/src/utils/documentIndex.ts +++ b/src/utils/documentIndex.ts @@ -39,7 +39,7 @@ const wsFolderIndex: Map = new Map(); const textDecoder = new TextDecoder("utf-8", { fatal: true }); /** The number of milliseconds that we should wait before sending a compile or delete request */ -const debounceDelay = 500; +const debounceDelay = 1000; /** * Create an object describing the file in `uri`. @@ -219,8 +219,8 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr const api = new AtelierAPI(uri); const conf = vscode.workspace.getConfiguration("objectscript", wsFolder); const syncLocalChanges: string = conf.get("syncLocalChanges"); - const sync: boolean = - api.active && (syncLocalChanges == "all" || (syncLocalChanges == "vscodeOnly" && touchedByVSCode.has(uriString))); + const vscodeChange = touchedByVSCode.has(uriString); + const sync = api.active && (syncLocalChanges == "all" || (syncLocalChanges == "vscodeOnly" && vscodeChange)); touchedByVSCode.delete(uriString); let change: WSFolderIndexChange = {}; if (isClassOrRtn(uri)) { @@ -237,7 +237,7 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr // 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. - if (vscode.window.activeTextEditor?.document.uri.toString() == uriString) { + if (vscodeChange && vscode.window.activeTextEditor?.document.uri.toString() == uriString) { compile([change.addedOrChanged]); } else { debouncedCompile(change.addedOrChanged);