Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
52 changes: 2 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,6 @@
"devDependencies": {
"@eslint/js": "^9.39.2",
"@intersystems-community/intersystems-servermanager": "^3.14.1",
"@types/istextorbinary": "2.3.1",
"@types/minimatch": "6.0.0",
"@types/mocha": "^10.0.10",
"@types/node": "22.13.14",
Expand Down Expand Up @@ -1757,7 +1756,6 @@
"@xmldom/xmldom": "^0.9.12",
"axios": "^1.20.0",
"iconv-lite": "^0.7.2",
"istextorbinary": "^7.0.0",
"minimatch": "^10.2.5",
"node-cmd": "^5.0.0",
"ws": "^8.21.0"
Expand Down
9 changes: 1 addition & 8 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import vscode = require("vscode");
import { isText } from "istextorbinary";
import { AtelierAPI } from "../api";
import {
documentContentProvider,
Expand Down Expand Up @@ -474,19 +473,13 @@ export async function namespaceCompile(): Promise<any> {

async function importFiles(files: vscode.Uri[], noCompile = false) {
if (!files.length) return;
const textDecoder = new TextDecoder();
const toCompile: (CurrentTextFile | CurrentBinaryFile)[] = [];
const rateLimiter = new RateLimiter(50);
await Promise.allSettled<void>(
files.map((uri) =>
rateLimiter.call(async () => {
const contentBytes = await vscode.workspace.fs.readFile(uri);
const curFile = currentFileFromContent(
uri,
isText(uri.path.split("/").pop(), Buffer.from(contentBytes))
? textDecoder.decode(contentBytes)
: Buffer.from(contentBytes)
);
const curFile = currentFileFromContent(uri, Buffer.from(contentBytes));
if (curFile) {
if (typeof curFile.content == "string" && isCompilable(curFile.name)) {
toCompile.push(curFile);
Expand Down
29 changes: 15 additions & 14 deletions src/utils/documentIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
isCompilable,
uriIsAncestorOf,
} from ".";
import { isText } from "istextorbinary";
import { AtelierAPI } from "../api";
import { compile, importFile } from "../commands/compile";

Expand Down Expand Up @@ -49,19 +48,22 @@ const debounceDelay = 1000;
*/
async function getCurrentFile(
uri: vscode.Uri,
forceText = false,
content?: string[] | Buffer
): Promise<CurrentTextFile | CurrentBinaryFile | null | undefined> {
if (content) {
// forceText is always true when content is passed
return currentFileFromContent(uri, Buffer.isBuffer(content) ? textDecoder.decode(content) : content.join("\n"));
}
try {
const contentBytes = await vscode.workspace.fs.readFile(uri);
const contentBuffer = Buffer.from(contentBytes);
if (!content) {
const contentBytes = await vscode.workspace.fs.readFile(uri);
content = Buffer.from(contentBytes);
}
return currentFileFromContent(
uri,
forceText || isText(uri.path.split("/").pop(), contentBuffer) ? textDecoder.decode(contentBytes) : contentBuffer
isClassOrRtn(uri.path) && Buffer.isBuffer(content)
? // We need the content as a string for classes and routines
textDecoder.decode(content)
: // string[] must be turned into string
Array.isArray(content)
? content.join("\n")
: content
);
} catch (error) {
// Either a vscode.FileSystemError from readFile()
Expand Down Expand Up @@ -191,7 +193,7 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr
files.forEach((file) =>
fsRateLimiter.call<WSFolderIndexChange | undefined>(async () => {
if (isClassOrRtn(file.path) || isImportableLocalFile(file)) {
return updateIndexInternal(file, documents, uris, true);
return updateIndexInternal(file, documents, uris);
}
return undefined;
})
Expand Down Expand Up @@ -257,7 +259,7 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr
const vscodeChange = touchedByVSCode.has(uriString);
const sync = api.active && (syncLocalChanges == "all" || (syncLocalChanges == "vscodeOnly" && vscodeChange));
touchedByVSCode.delete(uriString);
const change = await updateIndexInternal(uri, documents, uris, sync);
const change = await updateIndexInternal(uri, documents, uris);
if (!sync || (!change.addedOrChanged && !change.removed)) return;
if (change.addedOrChanged) {
// Create or update the document on the server
Expand Down Expand Up @@ -335,19 +337,18 @@ export async function updateIndex(uri: vscode.Uri, content?: string[] | Buffer):
if (!wsFolder) return {};
const index = wsFolderIndex.get(wsFolder.uri.toString());
if (!index) return {};
return updateIndexInternal(uri, index.documents, index.uris, true, content);
return updateIndexInternal(uri, index.documents, index.uris, content);
}

async function updateIndexInternal(
uri: vscode.Uri,
documents: WSFolderIndex["documents"],
uris: WSFolderIndex["uris"],
sync: boolean,
content?: string[] | Buffer
): Promise<WSFolderIndexChange> {
const result: WSFolderIndexChange = {};
const uriString = uri.toString();
const file = await getCurrentFile(uri, true, content);
const file = await getCurrentFile(uri, content);
if (!file) return result;
result.addedOrChanged = file;
const documentUris = documents.get(file.name) ?? [];
Expand Down
Loading