-
Notifications
You must be signed in to change notification settings - Fork 3
vscode upgrade #460
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
base: main
Are you sure you want to change the base?
vscode upgrade #460
Changes from all commits
3ac3033
3d93e6e
537c4d7
aaa7d66
a0360f2
e273eef
0c238ad
0d3fbe6
0caa63f
0670154
027a714
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,9 +36,164 @@ export class WorkaroundFeature implements StaticFeature { | |
| } | ||
| } | ||
|
|
||
| export class LogOutputChannelWrapper implements vscode.LogOutputChannel { | ||
| private readonly outputChannel: vscode.OutputChannel; | ||
| private readonly onDidChangeLogLevelEmitter = new vscode.EventEmitter<vscode.LogLevel>(); | ||
| private readonly disposables: vscode.Disposable[] = []; | ||
| private _logLevel: vscode.LogLevel; | ||
|
|
||
| readonly onDidChangeLogLevel: vscode.Event<vscode.LogLevel>; | ||
|
|
||
| constructor(outputChannel: vscode.OutputChannel, logLevel: vscode.LogLevel = vscode.env.logLevel) { | ||
| this.outputChannel = outputChannel; | ||
| this._logLevel = logLevel; | ||
| this.onDidChangeLogLevel = this.onDidChangeLogLevelEmitter.event; | ||
|
|
||
| this.disposables.push( | ||
| vscode.env.onDidChangeLogLevel((level) => { | ||
| this._logLevel = level; | ||
| this.onDidChangeLogLevelEmitter.fire(level); | ||
| }), | ||
| this.onDidChangeLogLevelEmitter, | ||
| ); | ||
| } | ||
|
|
||
| get logLevel(): vscode.LogLevel { | ||
| return this._logLevel; | ||
| } | ||
|
|
||
| get name(): string { | ||
| return this.outputChannel.name; | ||
| } | ||
|
|
||
| append(value: string): void { | ||
| this.info(value); | ||
| } | ||
|
|
||
| appendLine(value: string): void { | ||
| this.append(value); | ||
| } | ||
|
|
||
| clear(): void { | ||
| this.outputChannel.clear(); | ||
| } | ||
|
|
||
| replace(value: string): void { | ||
| this.clear(); | ||
| this.info(value); | ||
| } | ||
|
|
||
| show(preserveFocus?: boolean): void; | ||
| show(column?: vscode.ViewColumn, preserveFocus?: boolean): void; | ||
| show(columnOrPreserveFocus?: vscode.ViewColumn | boolean, preserveFocus?: boolean): void { | ||
| if (typeof columnOrPreserveFocus === 'number') { | ||
| this.outputChannel.show(columnOrPreserveFocus, preserveFocus); | ||
| } else { | ||
| this.outputChannel.show(columnOrPreserveFocus); | ||
| } | ||
| } | ||
|
|
||
| hide(): void { | ||
| this.outputChannel.hide(); | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| dispose(): void { | ||
| for (const disposable of this.disposables) { | ||
| disposable.dispose(); | ||
| } | ||
| this.outputChannel.dispose(); | ||
| } | ||
|
|
||
| trace(message: string, ...args: any[]): void { | ||
| this.writeLog(vscode.LogLevel.Trace, message, args, true); | ||
| } | ||
|
|
||
| debug(message: string, ...args: any[]): void { | ||
| this.writeLog(vscode.LogLevel.Debug, message, args); | ||
| } | ||
|
|
||
| info(message: string, ...args: any[]): void { | ||
| this.writeLog(vscode.LogLevel.Info, message, args); | ||
| } | ||
|
|
||
| warn(message: string, ...args: any[]): void { | ||
| this.writeLog(vscode.LogLevel.Warning, message, args); | ||
| } | ||
|
|
||
| error(error: string | Error, ...args: any[]): void { | ||
| if (!this.canLog(vscode.LogLevel.Error)) { | ||
| return; | ||
| } | ||
| if (error instanceof Error) { | ||
| this.appendFormattedLine(vscode.LogLevel.Error, this.formatMessage(error.stack ?? error.message, args)); | ||
| } else { | ||
| this.writeLog(vscode.LogLevel.Error, error, args); | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log wrapper ignores log levelMedium Severity The wrapper’s Reviewed by Cursor Bugbot for commit 0d3fbe6. Configure here. |
||
|
|
||
| private writeLog(level: vscode.LogLevel, message: string, args: any[], verbose = false): void { | ||
| if (!this.canLog(level)) { | ||
| return; | ||
| } | ||
| this.appendFormattedLine(level, this.formatMessage(message, args, verbose)); | ||
| } | ||
|
|
||
| private canLog(messageLevel: vscode.LogLevel): boolean { | ||
| return this._logLevel !== vscode.LogLevel.Off && this._logLevel <= messageLevel; | ||
| } | ||
|
|
||
| private appendFormattedLine(level: vscode.LogLevel, message: string): void { | ||
| this.outputChannel.append(`${this.getCurrentTimestamp()} [${this.stringifyLogLevel(level)}] ${message}\n`); | ||
| } | ||
|
|
||
| private formatMessage(message: string, args: any[], verbose = false): string { | ||
| const parts: any[] = [message, ...args]; | ||
| let result = ''; | ||
| for (let i = 0; i < parts.length; i++) { | ||
| let part = parts[i]; | ||
| if (part instanceof Error) { | ||
| part = verbose ? (part.stack ?? part.message) : part.message; | ||
| } else if (typeof part === 'object' && part !== null) { | ||
| try { | ||
| part = JSON.stringify(part); | ||
| } catch { | ||
| part = String(part); | ||
| } | ||
| } | ||
| result += (i > 0 ? ' ' : '') + String(part); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| private getCurrentTimestamp(): string { | ||
| const toTwoDigits = (value: number) => (value < 10 ? `0${value}` : `${value}`); | ||
| const toThreeDigits = (value: number) => (value < 10 ? `00${value}` : value < 100 ? `0${value}` : `${value}`); | ||
| const now = new Date(); | ||
| return `${now.getFullYear()}-${toTwoDigits(now.getMonth() + 1)}-${toTwoDigits(now.getDate())} ${toTwoDigits(now.getHours())}:${toTwoDigits(now.getMinutes())}:${toTwoDigits(now.getSeconds())}.${toThreeDigits(now.getMilliseconds())}`; | ||
| } | ||
|
|
||
| private stringifyLogLevel(level: vscode.LogLevel): string { | ||
| switch (level) { | ||
| case vscode.LogLevel.Trace: | ||
| return 'trace'; | ||
| case vscode.LogLevel.Debug: | ||
| return 'debug'; | ||
| case vscode.LogLevel.Info: | ||
| return 'info'; | ||
| case vscode.LogLevel.Warning: | ||
| return 'warning'; | ||
| case vscode.LogLevel.Error: | ||
| return 'error'; | ||
| default: | ||
| return 'off'; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async function activateServer(context: vscode.ExtensionContext) { | ||
| const workspaceClientInstanceId = 'chialisp'; | ||
| const outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel(workspaceClientInstanceId); | ||
| const rawOutputChannel: vscode.OutputChannel = vscode.window.createOutputChannel(workspaceClientInstanceId); | ||
| const outputChannel: vscode.LogOutputChannel = new LogOutputChannelWrapper(rawOutputChannel); | ||
| var ourExtensionPath = vscode.extensions.getExtension(ourExtension)?.extensionPath; | ||
|
|
||
| if (!ourExtensionPath) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| FROM codercom/code-server:4.96.4-focal | ||
| FROM codercom/code-server:4.125.0-focal | ||
| RUN sudo ln -s /usr/lib/code-server/lib/node /bin/node | ||
| COPY launch.json /home/coder/.vscode/launch.json |


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.
Append breaks output channel contract
Medium Severity
LogOutputChannelWrapperroutesappendandappendLinethroughinfo(), so each write is subject tocanLogat info level and gets a timestamp, level tag, and forced newline. That differs from a plainOutputChannel(and from nativeLogOutputChannellegacy writes), sovscode-languageclientoutput can disappear when the editor log level is above info or look garbled when multipleappendcalls should form one line.Additional Locations (1)
src/lsp.ts#L80-L84Reviewed by Cursor Bugbot for commit 027a714. Configure here.