Skip to content

Ignore duplicate file change events in local workspace folders #1539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged
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
12 changes: 11 additions & 1 deletion src/utils/documentIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr
// Limit FileSystemWatcher events that may produce a putDoc()
// request to 50 concurrent calls to avoid hammering the server
const restRateLimiter = new RateLimiter(50);
// A cache of the last time each file was last changed
const lastFileChangeTimes: Map<string, number> = new Map();
// Index classes and routines that currently exist
vscode.workspace
.findFiles(new vscode.RelativePattern(wsFolder, "{**/*.cls,**/*.mac,**/*.int,**/*.inc}"))
Expand All @@ -187,8 +189,10 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr
return;
}
const uriString = uri.toString();
const lastFileChangeTime = lastFileChangeTimes.get(uriString) ?? 0;
lastFileChangeTimes.set(uriString, Date.now());
if (openCustomEditors.includes(uriString)) {
// This class is open in a graphical editor, so its name will not change
// This class is open in a low-code editor, so its name will not change
// and any updates to the class will be handled by that editor
touchedByVSCode.delete(uriString);
return;
Expand All @@ -201,6 +205,12 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr
touchedByVSCode.delete(uriString);
return;
}
if (lastFileChangeTimes.get(uriString) - lastFileChangeTime < 300) {
// This file change event came too quickly after the last one to be a
// meaningful change triggered by the user, so consider it a duplicate
touchedByVSCode.delete(uriString);
return;
}
const api = new AtelierAPI(uri);
const conf = vscode.workspace.getConfiguration("objectscript", wsFolder);
const syncLocalChanges: string = conf.get("syncLocalChanges");
Expand Down