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

Button in vs-code to open a large error as a new file in open a new tab. #107

Open
MichaelDimmitt opened this issue May 10, 2024 · 15 comments
Labels
feature request Request a new feature

Comments

@MichaelDimmitt
Copy link

MichaelDimmitt commented May 10, 2024

Description:
Not sure if I should request this feature in this extension.
Please let me know if it should be posted in a different extension repository.

Describe the bug
When you hover to see a typescript error the content can be to large to view in the tooltip.

I understand there is a button that sends you here: https://ts-error-translator.vercel.app/ - however, that also cuts off the two types that that I want to visually compare to troubleshoot the error.

Expected behavior
Clicking a button from the tooltip, outputs the error in a new vs-code tab.

Original error
If this bug is related to an error that is not formatting well, please
attach the original error in a code block:

Screenshots
Screenshot 2024-05-10 at 12 48 57 PM

If there is interest for this and if it is possible.
I might try to put up a pr solving this.

Thank you, this extension is definitely helpful overall.

Regards,
Michael Dimmitt

ps. to make the example in the screenshot I added this to my typescript file: "noErrorTruncation": true,

@MichaelDimmitt MichaelDimmitt added the bug Something isn't working label May 10, 2024
@MichaelDimmitt

This comment was marked as off-topic.

@kevinramharak
Copy link
Contributor

@MichaelDimmitt I think you are looking for the noErrorTruncation option in the tsconfig.json.
The truncated error message is because that's what the typescript compiler generates as a diagnostic.

@MichaelDimmitt
Copy link
Author

MichaelDimmitt commented May 13, 2024

  1. I am looking for a button to open the error in a different tab. Because the tooltip that shows in vscode is too small to easily debug a large typescript error. @kevinramharak
  2. I did not mean to mark it as a bug, I think this would be better marked as a feature.
  3. If there is a shortcut or button to do this already I have not heard of it.

@MichaelDimmitt MichaelDimmitt changed the title Button in vs-code to open a large error as a new file. Button in vs-code to open a large error as a new file, or open a new tab. May 13, 2024
@MichaelDimmitt MichaelDimmitt changed the title Button in vs-code to open a large error as a new file, or open a new tab. Button in vs-code to open a large error as a new file in open a new tab. May 13, 2024
@kevinramharak
Copy link
Contributor

@MichaelDimmitt Apologies, i did not see your PS. I tried to reproduce it and ran into the truncation problem and assumed that was the case here.
This would indeed be a feature request. I think this could be implemented with the virtual documents API. The button could open a file in a new tab with a custom file scheme like pretty-ts-errors:, which the provider would then provide the document content formatted as markdown.

@kevinramharak
Copy link
Contributor

I have a 99% working implementation with the markdown code block syntax highlighting still missing:
image
Which opens the rendered markdown in a new tab:
image

But I'm struggling with getting the syntax highlighting in the rendered markdown for the custom embedded type.tmGrammar.json.

These instructions are supposed to help:

But I haven't figured it out yet. There icons that link to external sites to help explain the error are also missing, but the rest seems promising.

I'll try to make a full PR somewhere next week.

@yoavbls
Copy link
Owner

yoavbls commented May 18, 2024

@kevinramharak It looks very promising!
I tried to make a side panel with markdown a few months ago, but I faced some limitations.
Another option is to create a web side panel and use shiki for syntax highlighting like this plugin is doing:

https://github.com/mattbierner/vscode-docs-view/blob/master/src/codeHighlighter.ts

If you can share the partial PR with me I'll try to help :)

@kevinramharak
Copy link
Contributor

@yoavbls I did look into the Webview API but since it recommends first looking into the native API's I decided to try that first.
My MVP branch is located here: https://github.com/kevinramharak/pretty-ts-errors/tree/feature/107-button-to-open-error-in-new-tab.
It creates a link with a Command URI to invoke the markdown.showPreview command with an URI as argumented like: pretty-ts-errors:${uri.fsPath}.md?range=1:1-2:16
The range parameter represents a Range instance.
The textDocumentContentProvider registers itself to respond to the pretty-ts-errors: scheme and based on the fsPath and Range data it uses the uriStore to lookup the formatted markdown and returns it as the file contents.

@yoavbls
Copy link
Owner

yoavbls commented May 26, 2024

Looking good
So the only thing left for a working side panel is to render the types with syntax highlighting in the markdown panel?

@MichaelDimmitt
Copy link
Author

This is great, thank you for sharing that branch. @kevinramharak
It is really informative to see how you went about solving this problem!

I will attempt on my end forking what you are working on.
New to extensions though so no promises.

Even what you have in that branch would totally work for my purposes
However, I understand that this extension cares about the formatting. 🙂

Thanks again.

@MichaelDimmitt
Copy link
Author

I was going to sponsor both of you but only an option to sponsor @yoavbls ,
thanks for your work on this @kevinramharak !

@kevinramharak
Copy link
Contributor

Looking good So the only thing left for a working side panel is to render the types with syntax highlighting in the markdown panel?

@yoavbls A working side panel would require setting up the Webview API. But I assume it is largely the same flow.

@MichaelDimmitt Thanks for your generosity. I have not had the time yet to work on this. I hope to work out the MVP into something mergable this summer.

@yoavbls
Copy link
Owner

yoavbls commented Jul 10, 2024

I'm sorry that I still haven't found time for that but I hope I will do soon.
I really appreciate your donation @MichaelDimmitt ❤️
@kevinramharak I would like to give it to you, please open your profile for sponsorship 🙏🏼

@yoavbls yoavbls added feature request Request a new feature and removed bug Something isn't working labels Jul 10, 2024
@kevinramharak
Copy link
Contributor

@yoavbls Oh wow thank you. I applied for sponsorship, but its still pending. Was not aware anyone could just apply for it.
Im still planning to get this feature done. Hopefully before September ends.

@yoavbls
Copy link
Owner

yoavbls commented Aug 19, 2024

Of course, just let me know when the sponsorship option is approved

@yoavbls
Copy link
Owner

yoavbls commented Sep 29, 2024

Of course, just let me know when the sponsorship option is approved

Done 🙂
@kevinramharak

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

No branches or pull requests

3 participants