From 98c5f31bd6ae2a31fdec52ce38b41ff09308f94c Mon Sep 17 00:00:00 2001 From: Ivan Posti Date: Wed, 20 Jul 2022 10:52:26 +0200 Subject: [PATCH] [Markdown] Use system independent paths for pasted files GitOrigin-RevId: a0f53c80dc3ddc6c5ec11f3b7c7b275f2a373b15 --- .../plugins/markdown/editor/paste/EditorFileDropHandler.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/markdown/core/src/org/intellij/plugins/markdown/editor/paste/EditorFileDropHandler.kt b/plugins/markdown/core/src/org/intellij/plugins/markdown/editor/paste/EditorFileDropHandler.kt index 3bfc73dc8b94..b03065d1c722 100644 --- a/plugins/markdown/core/src/org/intellij/plugins/markdown/editor/paste/EditorFileDropHandler.kt +++ b/plugins/markdown/core/src/org/intellij/plugins/markdown/editor/paste/EditorFileDropHandler.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionManager import com.intellij.openapi.fileTypes.FileTypeRegistry import com.intellij.openapi.project.Project import com.intellij.openapi.ui.Messages +import com.intellij.openapi.util.io.FileUtil import com.intellij.psi.PsiFile import com.intellij.psi.util.PsiEditorUtil import com.intellij.refactoring.RefactoringBundle @@ -70,7 +71,7 @@ internal class EditorFileDropHandler: CustomFileDropHandler() { when (registry.getFileTypeByExtension(path.extension)) { imageFileType, SvgFileType.INSTANCE -> ImageUtils.createMarkdownImageText( description = path.name, - path = path.toString() + path = FileUtil.toSystemIndependentName(path.toString()) ) else -> createFileLink(path) } @@ -85,7 +86,8 @@ internal class EditorFileDropHandler: CustomFileDropHandler() { } private fun createFileLink(file: Path): String { - return "[${file.name}]($file)" + val independentPath = FileUtil.toSystemIndependentName(file.toString()) + return "[${file.name}]($independentPath)" } internal fun handleReadOnlyModificationException(project: Project, document: Document, block: () -> Unit) {