IJPL-189291 [markdown] Handle InvalidPathException

GitOrigin-RevId: 8e27c826ebd9effae7e12e59e7d27d6474e441b7
This commit is contained in:
Alexander Kuznetsov
2025-06-24 12:10:19 +00:00
committed by intellij-monorepo-bot
parent b63bbd7d7c
commit 0a369840d6
@@ -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<MarkdownHeaderInfo>? {