vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Do not show complete content after reload if output is cleared

Open nhedger opened this issue 1 year ago • 12 comments

Type: Bug

I'm building an extension that uses the LogOutputChannel to output some logs when the extension activates.

I started noticing that everytime I reloaded the window, I'd end up with the same logs twice: the logs from the previous activation, and the logs from the current activation.

I assumed that the channel wasn't cleared automatically so at first I manually cleared the output channel using the context menu action before reloading the window. Unfortunately, this still results in the logs from the previous activation being shown. Programmatically clearing the output channel using the clear method did not work either.

The only way I could the channel to clear was to completely restart VS Code.

I'm thinking maybe the buffer is not being cleared and when the window is reloaded, the logs from the current activation are appended to the logs from the previous one.

VS Code version: Code 1.86.1 (31c37ee8f63491495ac49e43b8544550fbae4533, 2024-02-07T09:09:01.236Z) OS version: Darwin x64 23.2.0 Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 2, 3, 3
Memory (System) 32.00GB (7.05GB free)
Process Argv
Screen Reader no
VM 0%

https://github.com/microsoft/vscode/assets/649677/d5fceb10-1003-4438-ae99-90665809634e

nhedger avatar Feb 11 '24 17:02 nhedger

It is designed that logs are retained on window reload

sandy081 avatar Feb 13 '24 17:02 sandy081

I understand persisting the logs between window reloads, but why persist them after having explicitly cleared them? This certainly feels counterintuitive.

nhedger avatar Feb 13 '24 18:02 nhedger

but why persist them after having explicitly cleared them

Good point.

sandy081 avatar Feb 19 '24 14:02 sandy081

Should this be reopened?

nhedger avatar Aug 02 '24 13:08 nhedger

As discussed in #232500, the behavior with regards to the log file written to disk is also different on WSL compared to MacOS:

const logger = vscode.window.createOutputChannel("My extension", { log: true });
  • Use Developer: Open Log File to open the log file for My extension.
  • On Linux (WSL2 Ubuntu), we observe that after a Developer: Reload Window, when using Open Log File again, a new log file is opened that VSCode neatly created for us in the folder exthost<some_number+1>. Here, <some_number is the number for the folder in which the log file resided prior to the window reload.
  • However, on MacOS (Darwin 23.6.0 arm64), we notice that the same logfile is reused and lines are only appended to it. Is there a way we can force a new log file to be created on this system as well? Or at least that the old logfile is cleared? logger.clear() or logger.dispose() does not seem to work, it only clears the log from the output pane but does not affect the log file.

Splines avatar Oct 31 '24 14:10 Splines

Could you reopen this issue @sandy081 ? You've acknowledged the problem, but it seems you forgot to reopen the issue. I'm afraid this won't ever get solved if it stays closed.

nhedger avatar Feb 23 '25 17:02 nhedger

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

This is not a feature request, but a bug report.

nhedger avatar Mar 04 '25 06:03 nhedger

Thanks for reopening @sandy081! I think the feature request tag should also be removed too, if you don't mind.

nhedger avatar Mar 04 '25 15:03 nhedger

I am sorry, this is not a bug, this is existing intended behaviour. To support this, we should support both behaviour. Hence tagged as feature request.

Thanks

sandy081 avatar Mar 07 '25 09:03 sandy081

I respectfully disagree. Explicitly clearing the logs does not actually clear them, which feels like a bug, wouldn't you agree?

nhedger avatar Mar 07 '25 09:03 nhedger

Agreed. I missed clearing the log action in the issue. Thanks for reminding that.

sandy081 avatar Mar 07 '25 09:03 sandy081