An output channel is a way to display information to the user of an extension. Logging data to an output channel is similar to logging information, but outputChannel.appendLine
is used instead of console.log
.
The output channel must be shared between function calls. In case the creation of an output channel is part of the command execution, a new output channel is created every time a command is executed and the old one isnβt automatically reused or removed.
vscode.commands.registerCommand
requires passing a function, which means you canβt define the input to the function at that time. This can be solved by calling the function in a lambda:
Preserving focus
The default behaviour when showing an output channel is to grab focus, which is not what I expected. To prevent the output channel from grabbing focus, add true
as input to show
(e.g., outputChannel.show(true)
).