Skip to content

Commit

Permalink
Match TS disc colon encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mkondratek committed May 15, 2024
1 parent 71362f0 commit 07542cc
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.vfs.VirtualFile
import java.nio.file.FileSystems
import java.util.Locale

class ProtocolTextDocument
private constructor(
Expand Down Expand Up @@ -48,7 +49,12 @@ private constructor(
}

private fun uriFor(file: VirtualFile): String {
return FileSystems.getDefault().getPath(file.path).toUri().toString()
val uri = FileSystems.getDefault().getPath(file.path).toUri().toString()
return uri.replace(Regex("file://(\\w):/")) {
val driveLetter =
it.groups[1]?.value?.lowercase(Locale.getDefault()) ?: return@replace it.value
"file:///$driveLetter%3A/"
}
}
}
}

0 comments on commit 07542cc

Please sign in to comment.