[recent files] IJPL-183215 Avoid large debug logs and consider files limit in a batch event

GitOrigin-RevId: 796df39600b956149a0e2ad9bb464dde1f65d2ed
This commit is contained in:
Nikita Katkov
2025-04-08 12:55:22 +02:00
committed by intellij-monorepo-bot
parent 5a9f8e3bdc
commit cf7040310b
2 changed files with 5 additions and 4 deletions

View File

@@ -101,8 +101,9 @@ internal class BackendRecentFilesModel(private val project: Project, private val
}
fun applyBackendChangesToAllFileKinds(changeKind: FileChangeKind, files: List<VirtualFile>) {
val reasonablyLimitedFilesList = files.take(bufferSize)
for (fileKind in RecentFileKind.entries) {
scheduleApplyBackendChanges(fileKind, changeKind, files)
scheduleApplyBackendChanges(fileKind, changeKind, reasonablyLimitedFilesList)
}
}

View File

@@ -84,14 +84,14 @@ class FrontendRecentFilesModel(private val project: Project) {
when (change) {
is RecentFilesEvent.ItemsAdded -> {
val toAdd = change.batch.map(::convertSwitcherDtoToViewModel)
LOG.debug("Adding items ${change.batch} to $targetFilesKind frontend model")
LOG.debug("Adding ${change.batch.size} items to $targetFilesKind frontend model")
targetModel.update { oldList ->
RecentFilesState(toAdd + (oldList.entries - toAdd.toSet()))
}
}
is RecentFilesEvent.ItemsUpdated -> {
val itemsToMergeWithExisting = change.batch.map(::convertSwitcherDtoToViewModel).associateBy { it }
LOG.debug("Updating items ${change.batch} in $targetFilesKind frontend model")
LOG.debug("Updating ${change.batch.size} items in $targetFilesKind frontend model")
targetModel.update { oldList ->
if (change.putOnTop) {
val newValuesToPutIntoFirstPosition = oldList.entries.mapNotNull { oldItem -> itemsToMergeWithExisting[oldItem] }
@@ -105,7 +105,7 @@ class FrontendRecentFilesModel(private val project: Project) {
}
}
is RecentFilesEvent.ItemsRemoved -> {
LOG.debug("Removing items ${change.batch} from $targetFilesKind frontend model")
LOG.debug("Removing ${change.batch.size} items from $targetFilesKind frontend model")
val toRemove = change.batch.mapNotNull { virtualFileId -> convertVirtualFileIdToViewModel(virtualFileId, project) }
targetModel.update { oldList ->
RecentFilesState(oldList.entries - toRemove.toSet())