Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import {
isClassOrRtn,
addWsServerRootFolderData,
getWsFolder,
exportedUris,
} from "./utils";
import { ObjectScriptDiagnosticProvider } from "./providers/ObjectScriptDiagnosticProvider";
import { DocumentLinkProvider } from "./providers/DocumentLinkProvider";
Expand Down Expand Up @@ -1253,8 +1254,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
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);
Expand Down
29 changes: 15 additions & 14 deletions src/utils/documentIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
Expand All @@ -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:")) {
Expand All @@ -142,7 +135,6 @@ function generateDeleteFn(wsFolderUri: vscode.Uri): (doc: string) => void {
);
}
});
docs.length = 0;
}, debounceDelay);
};
}
Expand Down Expand Up @@ -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(() => {});
Expand Down