Skip to content

Commit 5b4c18a

Browse files
committed
More client-side tweaks
1 parent 039d8d2 commit 5b4c18a

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

src/extension.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import {
106106
isClassOrRtn,
107107
addWsServerRootFolderData,
108108
getWsFolder,
109+
exportedUris,
109110
} from "./utils";
110111
import { ObjectScriptDiagnosticProvider } from "./providers/ObjectScriptDiagnosticProvider";
111112
import { DocumentLinkProvider } from "./providers/DocumentLinkProvider";
@@ -1253,8 +1254,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
12531254
vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) => {
12541255
return Promise.all(
12551256
e.files
1256-
.filter(notIsfs)
1257-
.filter(isClassOrRtn)
1257+
// Only attempt to adjust the names of classes and routines that are
1258+
// not server-side files and were not created due to an export
1259+
.filter((f) => notIsfs(f) && isClassOrRtn(f) && !exportedUris.has(f.toString()))
12581260
.map(async (uri) => {
12591261
// Determine the file name
12601262
const workspace = workspaceFolderOfUri(uri);

src/utils/documentIndex.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,11 @@ function generateCompileFn(): (doc: CurrentTextFile | CurrentBinaryFile) => void
8686
// Clear the previous timeout to reset the debounce timer
8787
clearTimeout(timeout);
8888

89-
// Compile right away if this document is in the active text editor
90-
// and there are no other documents in the queue. This is needed
91-
// to avoid noticeable latency when a user is editing a client-side
92-
// file, saves it, and the auto-compile kicks in.
93-
if (docs.length == 1 && vscode.window.activeTextEditor?.document.uri.toString() == doc.uri.toString()) {
94-
compile([...docs]);
95-
docs.length = 0;
96-
return;
97-
}
98-
9989
// Set a new timeout to call the function after the specified delay
10090
timeout = setTimeout(() => {
101-
compile([...docs]);
91+
const docsCopy = [...docs];
10292
docs.length = 0;
93+
compile(docsCopy);
10394
}, debounceDelay);
10495
};
10596
}
@@ -118,7 +109,9 @@ function generateDeleteFn(wsFolderUri: vscode.Uri): (doc: string) => void {
118109

119110
// Set a new timeout to call the function after the specified delay
120111
timeout = setTimeout(() => {
121-
api.deleteDocs([...docs]).then((data) => {
112+
const docsCopy = [...docs];
113+
docs.length = 0;
114+
api.deleteDocs(docsCopy).then((data) => {
122115
let failed = 0;
123116
for (const doc of data.result) {
124117
if (doc.status != "" && !doc.status.includes("#16005:")) {
@@ -142,7 +135,6 @@ function generateDeleteFn(wsFolderUri: vscode.Uri): (doc: string) => void {
142135
);
143136
}
144137
});
145-
docs.length = 0;
146138
}, debounceDelay);
147139
};
148140
}
@@ -241,7 +233,16 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr
241233
// Create or update the document on the server
242234
importFile(change.addedOrChanged)
243235
.then(() => {
244-
if (conf.get("compileOnSave")) debouncedCompile(change.addedOrChanged);
236+
if (conf.get("compileOnSave")) {
237+
// Compile right away if this document is in the active text editor.
238+
// This is needed to avoid noticeable latency when a user is editing
239+
// a client-side file, saves it, and the auto-compile kicks in.
240+
if (vscode.window.activeTextEditor?.document.uri.toString() == uriString) {
241+
compile([change.addedOrChanged]);
242+
} else {
243+
debouncedCompile(change.addedOrChanged);
244+
}
245+
}
245246
})
246247
// importFile handles any server errors
247248
.catch(() => {});

0 commit comments

Comments
 (0)