[find in files] IJPL-205277 add buffer to improve performance and responsiveness

GitOrigin-RevId: e0f3446c9b0b26774de82af695877f49e5b8eb60
This commit is contained in:
Vera Petrenkova
2025-09-01 19:09:42 +00:00
committed by intellij-monorepo-bot
parent 524e00b045
commit 5fc984e1bc
@@ -31,6 +31,7 @@ import fleet.rpc.client.RpcTimeoutException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.buffer
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch
@@ -86,10 +87,13 @@ open class FindAndReplaceExecutorImpl(val coroutineScope: CoroutineScope) : Find
projectId = project.projectId(),
filesToScanInitially = filesToScanInitially.map { it.rpcId() },
maxUsagesCount = maxUsagesCount
).let {
if (shouldThrottle) it.throttledWithAccumulation()
else it.map { event -> ThrottledOneItem(event) }
}.take(maxUsagesCount).collect { throttledItems ->
).take(maxUsagesCount)
.buffer(capacity = maxUsagesCount)
.let {
if (shouldThrottle) it.throttledWithAccumulation()
else it.map { event -> ThrottledOneItem(event) }
}
.collect { throttledItems ->
if (searchDisposable?.isDisposed == true) {
return@collect
}