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

support mime-type when showing source from non-files in editor #8182

Closed
weinand opened this issue Jun 27, 2016 · 8 comments
Closed

support mime-type when showing source from non-files in editor #8182

weinand opened this issue Jun 27, 2016 · 8 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality verified Verification succeeded
Milestone

Comments

@weinand
Copy link
Contributor

weinand commented Jun 27, 2016

If a debug adapter returns source from the sourceRequest, the debug UI only recognises the correct (language) type if the name attribute of the source has a proper file extension.
For this reason some debug adapters have to add an extension to the name artificially.

This feature request asks for a more direct mechanism based on a new 'mimeType' attribute on the SourceRequest response. If available the debug UI should configure the editor for this mime-type.

@weinand weinand added feature-request Request for new features or functionality debug Debug viewlet, configurations, breakpoints, adapter issues labels Jun 27, 2016
@isidorn
Copy link
Contributor

isidorn commented Jun 27, 2016

This should be possible -> will investigate in debt week thus assigning to July

@isidorn isidorn added this to the July 2016 milestone Jun 27, 2016
@isidorn
Copy link
Contributor

isidorn commented Jul 6, 2016

I have looked into this and it is possible to support this.
E.g passing 'text/x-c' as a mime type will show the source with the languge mode c set.

Assigning to @weinand to add mimeType to the protocl and once added I can look into supporting this on the vscode side

@weinand
Copy link
Contributor Author

weinand commented Jul 7, 2016

@isidorn I've added an mimeTypeattribute to the SourceResponse and node-debug returns text/javascript for source content without extension, e.g. 'eval' content.

@isidorn isidorn assigned isidorn and unassigned weinand Jul 7, 2016
@isidorn isidorn closed this as completed in d343b5e Jul 7, 2016
@weinand weinand added the verified Verification succeeded label Jul 7, 2016
@weinand
Copy link
Contributor Author

weinand commented Jul 7, 2016

@felixfbecker you might interested in this.

@felixfbecker
Copy link
Contributor

Wouldn't it be easier to use the VS Code language ID?
Another problem I have is that if you run code like eval("throw new Exception();") in PHP, my debugger will break inside it and report the eval code throw new Exception(); via a source request. However, VS Code will not syntax highlight this. I have to add an extra line

<?php
throw new Exception();

to the source to get syntax highlighting. That of course means I have to add an offset of 1 to every break and subtract 1 from every breakpoint, but only for source requests. Do you have a better solution for this?

@weinand
Copy link
Contributor Author

weinand commented Jul 7, 2016

@felixfbecker I've CCed you because I saw your code that adds the <?php. Instead of doing that you could just return the mime type in the SourceRequest response:

response.body = { content: source, mimeType: 'application/x-php' };

We are not using the language ID because that is a VS Code concept. A mime type is universal. If a debug adapter is run in a different context, it is easier to return a mime type than to return the correct language id.

@felixfbecker
Copy link
Contributor

@weinand Sure I could return the mime type instead of returning eval.php as the file name. But I will still have to add <?php, because otherwise VS Code will use HTML syntax highlighting

@weinand
Copy link
Contributor Author

weinand commented Jul 7, 2016

@felixfbecker I see.
A custom mime type could help here: the type would be associated with a 'php2' language id that is associated with a grammar for raw php (not embedded in html).

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants