Skip to content

Support debugger URI path style #3

Closed

Description

XDebug wants all file paths as file:// URI. I looked at the source code and saw that there is code implemented for this, but the property debuggerPathsAreUris is private, by default set to false and has no constructor property - in opposite to debuggerLinesAndColumnsStartAt1.

Activity

  1. felixfbecker commented on Mar 9, 2016

    @felixfbecker
    Author

    What's up with the Jan 2016 milestone? If you are looking for an implementation, you might want to look at my code, I just overwrote the convert functions ;)

  2. weinand commented on Mar 9, 2016

    @weinand
    Contributor

    Felix Becker (@felixfbecker) Before closing this feature, I'll have to write tests... But you can try this unverified and untested feature already (and it would actually help me finishing this ;-). On your debug session call setDebuggerPathFormat('uri'). After that the convert... methods should start converting between native paths and URIs.

    Please note:

    • VS Code uses native paths for now, and there are no plans to change this (that's the reason why the debugAdapter's initialize request returns an error for any value other than 'path').
    • paths used in the launch or attach requests are not spec'ed so their format is left open to the debug adapter developer. So you cannot use the convertClientPathToDebugger and convertDebuggerPathToClient because they assume a configured client format which might be different from what you are using in your launch config.
  3. modified the milestones: , Jan 2016 on Mar 9, 2016
  4. felixfbecker commented on Mar 9, 2016

    @felixfbecker
    Author

    I will probably keep my overwritten methods because I also resolve localSourceRoot with serverSourceRoot in there, but I'm pretty sure your implementation of uri2path is not enough.

    • You must call decodeURI on it to handle paths with spaces or special characters
    • Windows paths will have a trailing slash in the URI (at least when they come from XDebug)
      url.parse('file:///c:/users/felix').pathname === '/c:/users/felix', but it should be c:/users/felix
    • I didn't implement this, but some replace the colon with a |, so that may need to be checked too
    • You should call path.normalize() on the result to replace slashes with backslashes on Windows

    So it must be at least

        let filePath = decodeURI(url.parse(fileUri).pathname);
        // strip the trailing slash from Windows paths (indicated by a drive letter with a colon)
        // just checking process.platform will not work here because in a remote debugging scenario the OS of the client and debugger can differ
        if (/^\/[a-zA-Z]:\//.test(filePath)) { // network drives?
            filePath = filePath.substr(1);
        }
        // convert slashes to backslashes on Windows
        return path.normalize(filePath);

    For the other way I simply use the file-url package with {resolve: false}

    Hope this helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestRequest for new features or functionality

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions