From 0a369840d652840ffba85143ee580aadd66fcf05 Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Tue, 24 Jun 2025 14:09:18 +0200 Subject: [PATCH] IJPL-189291 [markdown] Handle InvalidPathException GitOrigin-RevId: 8e27c826ebd9effae7e12e59e7d27d6474e441b7 --- .../backend/services/MarkdownLinkOpenerRemoteApiImpl.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/markdown/core/backend/src/com/intellij/markdown/backend/services/MarkdownLinkOpenerRemoteApiImpl.kt b/plugins/markdown/core/backend/src/com/intellij/markdown/backend/services/MarkdownLinkOpenerRemoteApiImpl.kt index 81e91ff0fb98..ce4b00ee4da2 100644 --- a/plugins/markdown/core/backend/src/com/intellij/markdown/backend/services/MarkdownLinkOpenerRemoteApiImpl.kt +++ b/plugins/markdown/core/backend/src/com/intellij/markdown/backend/services/MarkdownLinkOpenerRemoteApiImpl.kt @@ -27,6 +27,7 @@ import org.intellij.plugins.markdown.service.MarkdownLinkOpenerRemoteApi import java.io.IOException import java.net.URI import java.net.URISyntaxException +import java.nio.file.InvalidPathException import java.nio.file.Path internal class MarkdownLinkOpenerRemoteApiImpl : MarkdownLinkOpenerRemoteApi { @@ -96,13 +97,15 @@ internal class MarkdownLinkOpenerRemoteApiImpl : MarkdownLinkOpenerRemoteApi { } } val containingFile = virtualFileId?.virtualFile()?.parent ?: return null - val targetFile = try { + return try { containingFile.findFile(link.trimAnchor()) } catch (_: IOException) { null } - return targetFile + catch (_: InvalidPathException) { + null + } } private fun collectHeaders(anchor: String, targetFile: VirtualFile, project: Project): List? {