Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ComFreek opened this issue Jun 29, 2023 · 5 comments
Open

Comments

@ComFreek
Copy link
Member

No description provided.

@ComFreek
Copy link
Member Author

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

@Jazzpirate
Copy link
Collaborator

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

@ComFreek
Copy link
Member Author

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
Copy link
Collaborator

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
Copy link

bessw commented Jul 8, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants