Skip to content

Commit d3f45e9

Browse files
committed
Add a maximum size to the local lsp log buffer
1 parent b68c35a commit d3f45e9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

vscode-dotty/src/tracer.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,31 @@ export class Tracer {
281281
}
282282

283283
let log: string = ''
284+
let messageCounter: number = 0
285+
// Avoid filling the user memory with log messages
286+
let maxLocalMessages: number = 1000
284287
return {
285288
name: 'websocket',
286289

287290
append: (value: string) => {
291+
messageCounter++
292+
if (messageCounter > maxLocalMessages) {
293+
messageCounter = 0
294+
localOutputChannel.clear()
295+
}
296+
288297
localOutputChannel.append(value)
289298
if (this.tracingConsent.get() === 'Deny') return
290299
log += value
291300
},
292301

293302
appendLine: (value: string) => {
303+
messageCounter++
304+
if (messageCounter > maxLocalMessages) {
305+
messageCounter = 0
306+
localOutputChannel.clear()
307+
}
308+
294309
localOutputChannel.appendLine(value)
295310
if (this.tracingConsent.get() === 'Deny') {
296311
log = ''

0 commit comments

Comments
 (0)