Skip to content

Commit e80fdcb

Browse files
PY-86744: Ignore cases when comparing project names and paths and add test.
When dropping existing modules using `removeFakeModuleAndConflictingEntities` we should ignore case. GitOrigin-RevId: 2314f1916d1f2e43bce699703bdf8800c543f6b3
1 parent 0f12f79 commit e80fdcb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • python/python-pyproject/src/com/intellij/python/pyproject/model/internal/workspaceBridge

python/python-pyproject/src/com/intellij/python/pyproject/model/internal/workspaceBridge/workspaceTools.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.intellij.python.pyproject.model.internal.workspaceBridge
22

33
import com.intellij.openapi.project.Project
44
import com.intellij.openapi.util.NlsSafe
5+
import com.intellij.openapi.vfs.VirtualFileManager
56
import com.intellij.platform.backend.workspace.workspaceModel
67
import com.intellij.platform.workspace.jps.entities.*
78
import com.intellij.platform.workspace.storage.EntitySource
@@ -280,16 +281,17 @@ private data class PyProjectTomlBasedEntryImpl(
280281
* @see com.intellij.openapi.project.impl.getOrInitializeModule
281282
*/
282283
private fun removeFakeModuleAndConflictingEntities(storage: MutableEntityStorage, newModules: Sequence<ModuleEntity>) {
283-
val contentsToRemove = newModules.flatMap { content -> content.contentRoots.map { it.url } }.toSet()
284-
val namesToRemove = newModules.map { it.name }.toSet()
284+
val vfsManager = VirtualFileManager.getInstance()
285+
val contentsToRemove = newModules.flatMap { content -> content.contentRoots.map { vfsManager.findFileByUrl(it.url.url)!! } }.toSet()
286+
val namesToRemove = newModules.map { it.name.lowercase() }.toSet()
285287
val modulesToRemove = storage.entities(ModuleEntity::class.java)
286288
.filter { moduleEntity ->
287289
moduleEntity.type == PYTHON_MODULE_ID // Python module
288290
&& (
289291
// Intersects with new module content root
290-
moduleEntity.contentRoots.map { it.url }.any { it in contentsToRemove } ||
292+
moduleEntity.contentRoots.map { vfsManager.findFileByUrl(it.url.url) }.any { it in contentsToRemove } ||
291293
// Intersects by name
292-
moduleEntity.name in namesToRemove ||
294+
moduleEntity.name.lowercase() in namesToRemove ||
293295
// Auto-generated, temporary module
294296
moduleEntity.entitySource is NonPersistentEntitySource
295297
)

0 commit comments

Comments
 (0)