-
Notifications
You must be signed in to change notification settings - Fork 75
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: show at most one decoration per line #598
Conversation
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.
A test would be nice!
src/extension.ts
Outdated
@@ -675,25 +675,23 @@ export class Extension implements RunHooks { | |||
activeDecorations.push({ range: location.range }); | |||
} | |||
|
|||
const completedDecorations: vscodeTypes.DecorationOptions[] = []; | |||
const completedDecorations: Record<number, vscodeTypes.DecorationOptions> = {}; | |||
for (const { location, duration } of completed) { | |||
if (uriToPath(location.uri) === uriToPath(editor.document.uri)) { |
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.
drive-by I would pre-compute the editor's uri instead of doing it 1000 times. Maybe even store decorations by line from the get go.
the previous PR already added a good test: playwright-vscode/tests/decorations.spec.ts Lines 90 to 111 in a95208d
|
Is there a way to config this? These decorations were something i relied on heavily in my debug flow, like to get a sense of how many iterations a loop took, which logic branches were seeing heavy traffic in a loop etc. This was not something that needed to be "fixed". :( |
That's good feedback! This fix is mostly for performance reasons. We need to limit the decorations in some way, otherwise VSCode gets overloaded. Let's think about what a middle ground would be where there's no performance problems, but your debug flow also isn't affected. When you debug your tests that way, do you run a single test, or do you run all tests in file? We could try only engaging this optimisation if there's more than one test being run. Let me know what you think would be a good solution! |
Gratitude for the swift reply! In situations where I'm paying attention to the decorations, I'm almost definitely running a single test. I generally set most loops to 10.
This seems like a great middle ground, i'd be happy with. Another potential solution would be including some sort of counter in the decoration alongside the elapsed time. So it would tell you that {the 5th execution of this line of code took 400ms} or something to that effect. The decorators really have proven very useful while authoring a test or light debugging (means I don't have to launch debugger or PW Inspector). And since the decorations persist after the test is done, I can still refer to them as tinker with the app or test script. So i really appreciate taking this into consideration :) also love the other updates in this release. Particularly the playwright drawer! |
Thanks! I like the counter and will open a PR for it. We like having issues for each change we ship - could you open this as a feature request over in the |
Will do! Gratitude :) |
Follow-up to #590.
Instead of capping the number of decorations per file, we now show at most one decoration per line. This still places a good upper limit so we don't overwhelm VS Code rendering with too many decorations. But it also prevents the confusing UI of decorations abruptly cutting off.
Screen.Recording.2025-01-17.at.10.32.07.mov