Skip to content

Do not re-index deleted files #2078

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
Mar 21, 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
2 changes: 1 addition & 1 deletion Sources/SemanticIndex/SemanticIndexManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ package final actor SemanticIndexManager {
package func filesDidChange(_ events: [FileEvent]) async {
// We only re-index the files that were changed and don't re-index any of their dependencies. See the
// `Documentation/Files_To_Reindex.md` file.
let changedFiles = events.map(\.uri)
let changedFiles = events.filter { $0.type != .deleted }.map(\.uri)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not be marking preparation for dependent targets out-of-date for deleted files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we can’t rely on being able to get the target that the file used to be part of. The build system might have already processed the removal of the file, which means that it won’t give us any targets for the file.

This should happen through the build system. It also receives the workspace/didChangeWatchedFiles notification and should send us a buildTargets/didChange notification if the deletion of the file changed that target. And we mark the file’s target as out-of-date based on this from SemanticIndexManager.buildTargetsChanged.

Does this make sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, yeah makes sense

await indexStoreUpToDateTracker.markOutOfDate(changedFiles)

// Preparation tracking should be per file. For now consider any non-known-language change as having to re-prepare
Expand Down