-
-
Notifications
You must be signed in to change notification settings - Fork 111
Add inline console.log display feature #668
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
Conversation
Co-authored-by: sheremet-va <[email protected]>
Co-authored-by: sheremet-va <[email protected]>
Co-authored-by: sheremet-va <[email protected]>
sheremet-va
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.
Let's enable this feature by default
| } | ||
|
|
||
| // Origin format is typically: file:line:column | ||
| // Example: /path/to/file.ts:10:5 |
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.
This is an incorrect assumption. origin is a stack trace string without the error message. For it to appear we also need to set printConsoleTrace to true in the config.
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.
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.
Fixed in commit ${git_hash}. Updated the parsing logic to handle stack trace strings properly. The parser now:
- Searches through multi-line stack traces
- Handles formats like
at functionName (file:///path/to/file.ts:10:5) - Supports file:// protocol and decodes URI components
- Extracts the first valid file reference from the trace
Also updated the documentation to note that printConsoleTrace: true is required in the Vitest config for this feature to work.
Co-authored-by: sheremet-va <[email protected]>
Done in commit ${git_hash}. Changed the default from |
| // at Object.<anonymous> (/path/to/file.ts:10:5) | ||
| // We look for the first line that contains a file path with line:column | ||
|
|
||
| const lines = origin.split('\n') |
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.
@copilot use parseErrorStacktrace from @vitest/utils/source-map instead. You should do that in the worker thread (packages/worker and packages/worker-legacy) before sending the log via RPC.
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.
Done in commit ${git_hash}. Now using parseErrorStacktrace from @vitest/utils/source-map in both worker and worker-legacy reporter threads. The parsed location is sent via RPC as part of an extended ExtensionUserConsoleLog type, and the extension's InlineConsoleLogManager simply uses the pre-parsed location.
Co-authored-by: sheremet-va <[email protected]>
|
…trip ANSI codes Co-authored-by: sheremet-va <[email protected]>
Done in commit ${git_hash}:
|
|
Co-authored-by: sheremet-va <[email protected]>
Done in commit ${git_hash}:
|
|
When I am editing the file and change the number of lines by adding new ones or removing old ones, the log keeps being rendered on the old line. Fix that |
Co-authored-by: sheremet-va <[email protected]>
Fixed in commit ${git_hash}. Console logs are now automatically cleared when a file is edited. This prevents stale line numbers when lines are added or removed. The logs will reappear at the correct positions when tests run again. |
This is not what I want. I want the log to stay around the code where it was when the file is updated (but not saved yet). For example,
The same is applied to removing the line, it should dynamically keep the position |
Co-authored-by: sheremet-va <[email protected]>
... Fixed in commit ${git_hash}. Console logs now dynamically track line number changes as you edit:
The line numbers are adjusted in real-time based on document change events, calculating the net change in lines and updating all affected console log positions accordingly. |
packages/extension/src/runner.ts
Outdated
| testRun.appendOutput( | ||
| formatTestOutput(content), | ||
| formatTestOutput(consoleLog.content), | ||
| undefined, |
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.
Actually, vscode already supports showing logs. If you provide a vscode.Location here, everything will be handled automatically and you can remove your class and simplify the implementation
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.
Done in commit ${git_hash}. Removed the custom InlineConsoleLogManager class and simplified the implementation by using VSCode's built-in location support. Now passing vscode.Location to testRun.appendOutput() and VSCode handles the inline display automatically. This reduced the code by ~200 lines while providing the same functionality.
Co-authored-by: sheremet-va <[email protected]>
sheremet-va
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.
@copilot remove showConsoleLogInline option
Co-authored-by: sheremet-va <[email protected]>
Done in commit ${git_hash}. Removed the |
Implements inline display of
console.logoutput in the editor, addressing #447. This feature allows users to see console output directly next to the lines that produced it, similar to what Julia VSCode extension and Quokka.js provide.Features
parseErrorStacktracein worker threads to extract file locationsImplementation Details
Configuration
printConsoleTrace: truein Vitest configuration so users don't need to manually configure itArchitecture
parseErrorStacktracefrom@vitest/utils/source-mapExtensionUserConsoleLogtypevscode.LocationwithTestRun.appendOutput()- VSCode handles inline display automaticallyBehavior
Testing
The feature can be tested with the existing
samples/basic-v4/test/console.test.tsfile by running the tests and observing console output appearing inline in the editor.Quality Assurance
Fixes #667
Original prompt
Fixes #667
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.