UniFormal / VSCode-MMT

MMT plugin for Visual Studio Code
https://uniformal.github.io
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Fix VSCode URI <-> OS file paths conversion hacks once and for all #2

Open ComFreek opened 1 year ago

ComFreek commented 1 year ago

@Jazzpirate Have you so far encountered an ultimately satisfying solution (e.g., for mmt-stex)?

Jazzpirate commented 1 year ago

I assume that means the current solution does not work? As far as I can tell, it does (for mmt-stex)...

ComFreek commented 1 year ago

Workarounds are spread all over the place in mmt-lsp and mmt-stex as far as I can tell. I'd like to extract every such workaround into a single combined method.

I built something:

object Utils {
  def vscodeURIToFile(uri: URI): File = {
    if (uri.scheme.contains("file")) {
      val filePath = (uri.path match {
        case driveLetter :: xs if driveLetter.matches("[a-zA-Z](:|%3A)") =>
          (driveLetter.charAt(0).toUpper + ":") :: xs
        case x => x
      }).mkString(java.io.File.separator)

      File(filePath)
    } else { // fallback
      File(uri.toString)
    }
  }
}

Any thoughts?

Jazzpirate commented 1 year ago

I think this should go into the existent methods for converting URIs - they are already used all over the place and it's probably a good thing if the URI used to identify documents is a valid file URI (if it is one)...?

bessw commented 4 months ago

The VSCode Extension is giving me error messages like this every time I save a file:

Internal error: file `d:\<path_to_my_project_folder>\UFrameIT-Install\archives\MathHub\FrameIT\frameworld\source\Scrolls\TriangleScrolls.mmt` requested to build was not communicated to be open to LSP server.
Open documents known to LSP server are: file:///D:/<path_to_my_project_folder>/UFrameIT-Install/archives/MathHub/FrameIT/frameworld/source/Scrolls/TriangleScrolls.mmt.

Is there a workaround to be able to use the extension in its current version?