From 067fef45446a617f90905e982489f0edd68cad99 Mon Sep 17 00:00:00 2001 From: Henry Wylde Date: Fri, 11 Apr 2025 14:42:47 +1200 Subject: [PATCH] RUBY-34028 use `lockMaybeCancellable` in `TextMateServiceImpl#ensureInitialized` Read/write actions are sometimes dependent on data from text mate service, as it helps determine file types. However, if another thread is already initializing the service, then the current thread may block without cancellation checks until initialization is complete. Now, it's possible to check for cancellation while waiting on the lock. (cherry picked from commit 4739498b0dea1389a89fe041e6fbd8001f6d3220) IJ-CR-161773 GitOrigin-RevId: a0d7878666bd9d29a35faef0da57e0bd8dbfbdd1 --- .../src/org/jetbrains/plugins/textmate/TextMateServiceImpl.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/textmate/src/org/jetbrains/plugins/textmate/TextMateServiceImpl.kt b/plugins/textmate/src/org/jetbrains/plugins/textmate/TextMateServiceImpl.kt index 0b930244a245..fe817cf632fc 100644 --- a/plugins/textmate/src/org/jetbrains/plugins/textmate/TextMateServiceImpl.kt +++ b/plugins/textmate/src/org/jetbrains/plugins/textmate/TextMateServiceImpl.kt @@ -15,6 +15,7 @@ import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.IntellijInternalApi import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.util.text.Strings +import com.intellij.util.progress.lockMaybeCancellable import kotlinx.coroutines.CoroutineScope import org.jetbrains.annotations.NonNls import org.jetbrains.annotations.TestOnly @@ -239,7 +240,7 @@ class TextMateServiceImpl(private val myScope: CoroutineScope) : TextMateService private fun ensureInitialized() { if (!isInitialized) { - registrationLock.lock() + registrationLock.lockMaybeCancellable() try { if (isInitialized) return registerBundles(fireEvents = false)