-
-
Notifications
You must be signed in to change notification settings - Fork 99
reimplement button-to-open-in-new-tab + custom webview #133 (monorepo) #152
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
base: main
Are you sure you want to change the base?
Conversation
|
@yoavbls I ported the changes from I think this is enough of poc to confirm this works and is a better approach. Maybe we start with implementing it with the default dark/light highlighters |
|
wowwww I'm so excited to see that this POC is working! |
|
@yoavbls I think we still need these parts:
The main change is that instead of executing the We could embed it all in the command that creates the webview, but having the custom text document content provider forces a separation of concerns. Which I think is a good thing here. During prototyping of this and the l10n draft I ran into the issue that passing the diagnostic as a string and performing string replacements makes it quite difficult to reason about the state of the string and what is and isn't part of it. For example removing the I also suspect that the heavy use of regexes is part of the performance issues some people experience (although pretty sure it's also caused by huge projects with lots of files). So if there is a way to implement a more abstract representation of the (formatted) diagnostic, it could help, maybe not so much in this issue, but for future features and changes. Something more like: type FormattedDiagnosticPartType = 'text' | 'codeblock' | 'icon' | 'link';
type FormattedDiagnosticPart = { type: FormattedDiagnosticPartType, text: string }
interface FormattedDiagnostic {
parts: FormattedDiagnosticPart[];
code: number;
location: Uri;
range: Range;
}I don't think we need it in this implementation, but keeping it in mind while implementing could really help to figure out if we need it and how a consuming API would use a data structure instead of a string. |
|
The old implementation was pretty easy to stitch to the new one, the hardest parts were figuring out CSP and the way we link to a symbol had to change. It's a bit smarter now as well, so it wont open links in the preview in the same active panel. Code needs a bit of cleanup, but the feature is very close to complete. |
yoavbls
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't review everything yet but I tested it out and it's amazing! I could not wait to merge it 😀
The main things should be done before:
- Upgrade
vscode-shiki-bridge - Use the user's theme for the code blocks
- Get rid of the previous logic meant for the markdown-based solution instead of the webview.
- Make the panel update instead of opening a new one
- Make the persistent panel on the explorer section update when clicking on a new error. I really liked this one
Thank you for all of this work
@kevinramharak @MichaelDimmitt
|
@yoavbls I think this is almost done now. Just needs to use the The custom markdown rendering was a bit buggy and generating incorrect HTML which messed up the preview. I ended up trying to integrate
I think having this setup works well, as when I use my laptop with a smaller screen, the preview panel is often not large enough, so being able to open any error in a new tab is very helpful. The view in the explorer panel now follows the cursor/selection, and feels pretty good. I initially cleared the panel when moving the cursor to a selection without an error, but that can be annoying, so now it just shows the last error for the code you selected. This solves a lot of issues with the hover not being copiable (#155), as both the new tab preview and the explorer panel allow for selecting and copying text. Additionally the new copy button #156 allows for copying the whole error message, and each code block now has a copy button. I added a notification message to give some user feedback that the click on the button actually did something. If you can take a look at yoavbls/vscode-shiki-bridge#2 and create a release for it, then all that remains is update the highlighting code to use the user theme, and this should be ready to go. |
|
@yoavbls You happened to push the update, so I stitched it together. I tried it with my own theme and another theme. I think this is now complete. There could be some QOL things like loading new themes when the theme changes, but it's nothing a restart or reload of VSCode won't fix. |
|
Great! yes It's fine if a restart is required in case there is a new extension or theme. |
|
Ill check on my side as well! |
|
@MichaelDimmitt I will take another look tomorrow and see what is missing.
|
|
I fixed it with 6700a52. Unfortunatly the whitelisted badge providers require to embed the vscode extension icon as a base64 embedded png. But using a markdown reference, its not to ugly. I had to use the flat white icon for cursor instead of the original one, as its the only one imgshields provides. This allows for building the I think the infinite loop on I fixed the copy type button, the implementation was a bit hacky dumping the content in an HTML attrivute, now it just copies the As for the type codeblocks not wrapping that is strange, I see the following: Does it wrap in the hover prettified error? Can you try opening the developer tools from VS Code and see what the HTML is of those codeblocks? Anything in a If needed we can use Shiki's output to add some CSS, as each line will be wrapped in a |
|
Awesome, I will grab latest and test it out |
|
TLDR: Works, thanks! |
| padding: 16px; | ||
| overflow-x: auto; | ||
| margin: 1em 0; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of css variables here to get the vscode themes!
I think that is what is going on here alongside TmLanguage-Syntax-Highlighter
and these libraries: markdown-exit, shiki, and vscode-shiki-bridge
MichaelDimmitt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read through the pr, functionality works on my end.
Local development setup was a little difficult but I got it figured out.
It looks like the only outstanding task is writing a script to move the codicon.css file out of nodemodules instead of keeping your own version? But probably out of scope of this pr.
Thanks for adding this! @kevinramharak and @yoavbls
| Every penny will be invested in other contributors to the project, especially ones that work | ||
| on things that I can't be doing myself like adding support to the extension for other IDEs 🫂 | ||
|
|
||
| ## Contribution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you want your contribution.md file to have developer setup instructions for getting debugging environment up and running. The dev setup has changed a bit since the mono repo update. But also this change might be out of scope of this pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought there was an issue for this, but I cant find it. This is indeed on the todo list after the monorepo setup. I will do this next, as it is intended to easily setup and contribute to this repo
| import { getUserLangs, getUserTheme } from "vscode-shiki-bridge"; | ||
| import { HighlighterCore, createHighlighterCore } from "shiki/core"; | ||
| import { createOnigurumaEngine } from "shiki/engine/oniguruma"; | ||
| import { createMarkdownExit, type MarkdownExit } from "markdown-exit"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this file is the main change and uses markdown-exit, shiki, and vscode-shiki-bridge.
…freshed when the original diagnostic no longer exists
|
@MichaelDimmitt That is very helpful. If you want, you can create a separate issue for it, but I will probably have some time this week to create and fix the |










Reimplemented #133 but with the monorepo setup. Used a new branch to avoid having to solve the merge errors that would come from trying to merge
mainback into that branch.Whats left:
vscode-codeiconicon font (example)Open in new Tablink in the Markdown preview (its there, just not shown because the icons don't show up)Maybe take another stab at injecting thethis is not needed if we usetypegrammarvscode-shiki-bridgeWe can also extend the. Some references are:markdown-itas @MichaelDimmitt also mentionedSome of the bugs/limitations can be discovered in how the markdown preview is implemented at markdown-language-features
This does indicate that a custom webview could be a better option, as it would be a lot less limiting. As for placement, a custom webview can be rendered pretty much everywhere, as an editor tab or part of the activity bar, so we could add configuration to let the user choose where to render it, with a sensible default.