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

fix: show at most one decoration per line #598

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Jan 17, 2025

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

@Skn0tt Skn0tt requested a review from pavelfeldman January 17, 2025 09:35
@Skn0tt Skn0tt self-assigned this Jan 17, 2025
Copy link
Member

@pavelfeldman pavelfeldman left a 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)) {
Copy link
Member

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.

@Skn0tt
Copy link
Member Author

Skn0tt commented Jan 20, 2025

A test would be nice!

the previous PR already added a good test:

test('should limit highlights', async ({ activate }) => {
const { vscode, testController } = await activate({
'playwright.config.js': `module.exports = { testDir: 'tests' }`,
'tests/test.spec.ts': `
import { test, expect } from '@playwright/test';
test('pass', async () => {
for (let i = 0; i < 2000; i++) {
expect(i).toBe(i);
}
});
`,
});
await vscode.openEditors('**/test.spec.ts');
await new Promise(f => testController.onDidChangeTestItem(f));
await testController.run();
const decorationsLog = vscode.window.activeTextEditor.renderDecorations(' ');
const lastState = decorationsLog.substring(decorationsLog.lastIndexOf('------'));
expect(lastState.split('\n').length).toBeLessThan(2000);
});

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

Successfully merging this pull request may close these issues.

2 participants