This repository was archived by the owner on Oct 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,13 @@ import * as vscode from "vscode";
5
5
import { performance } from "perf_hooks" ;
6
6
7
7
export class BufferedOutputChannel implements vscode . Disposable {
8
- private TIMING_BUFFER : number = 300 ;
9
-
10
8
private _buffer : string [ ] ;
11
9
private timer : NodeJS . Timer ;
12
10
private _lastFlushTime : number ;
13
11
14
- public constructor ( private outputCallback : ( value : string ) => void ) {
12
+ public constructor ( private outputCallback : ( value : string ) => void , private flushIntervalMs : number ) {
15
13
this . _buffer = [ ] ;
16
- this . timer = setInterval ( ( ) => this . tryFlush ( ) , this . TIMING_BUFFER ) ;
14
+ this . timer = setInterval ( ( ) => this . tryFlush ( ) , this . flushIntervalMs ) ;
17
15
this . _lastFlushTime = Number . NEGATIVE_INFINITY ;
18
16
}
19
17
@@ -24,7 +22,7 @@ export class BufferedOutputChannel implements vscode.Disposable {
24
22
25
23
private tryFlush ( ) {
26
24
const currentTime = performance . now ( ) ;
27
- if ( this . _buffer && this . _buffer . length > 0 && currentTime - this . _lastFlushTime > this . TIMING_BUFFER ) {
25
+ if ( this . _buffer . length > 0 && currentTime - this . _lastFlushTime > this . flushIntervalMs ) {
28
26
this . outputCallback ( this . _buffer . join ( '' ) ) ;
29
27
this . _lastFlushTime = currentTime ;
30
28
this . _buffer = [ ] ;
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ export class SerialMonitor implements vscode.Disposable {
60
60
defaultBaudRate = SerialMonitor . DEFAULT_BAUD_RATE ;
61
61
}
62
62
this . _outputChannel = vscode . window . createOutputChannel ( SerialMonitor . SERIAL_MONITOR ) ;
63
- this . _bufferedOutputChannel = new BufferedOutputChannel ( this . _outputChannel . append ) ;
63
+ this . _bufferedOutputChannel = new BufferedOutputChannel ( this . _outputChannel . append , 300 ) ;
64
64
this . _currentBaudRate = defaultBaudRate ;
65
65
this . _portsStatusBar = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , constants . statusBarPriority . PORT ) ;
66
66
this . _portsStatusBar . command = "arduino.selectSerialPort" ;
@@ -85,13 +85,15 @@ export class SerialMonitor implements vscode.Disposable {
85
85
} ) ;
86
86
}
87
87
public get initialized ( ) : boolean {
88
- return ! ! this . _bufferedOutputChannel ;
88
+ return ! ! this . _outputChannel ;
89
89
}
90
90
91
91
public dispose ( ) {
92
92
if ( this . _serialPortCtrl && this . _serialPortCtrl . isActive ) {
93
93
return this . _serialPortCtrl . stop ( ) ;
94
94
}
95
+ this . _outputChannel . dispose ( ) ;
96
+ this . _bufferedOutputChannel . dispose ( ) ;
95
97
}
96
98
97
99
public async selectSerialPort ( vid : string , pid : string ) {
You can’t perform that action at this time.
0 commit comments