@@ -26,7 +26,19 @@ export interface ConnectionOptions {
26
26
27
27
export default class Instance {
28
28
private connection : IBMi | undefined ;
29
- private outputChannel : vscode . OutputChannel = vscode . window . createOutputChannel ( `Code for IBM i` ) ;
29
+
30
+ private output = {
31
+ channel : vscode . window . createOutputChannel ( `Code for IBM i` ) ,
32
+ content : `` ,
33
+ writeCount : 0
34
+ } ;
35
+
36
+ private resetOutput ( ) {
37
+ this . output . channel . clear ( ) ;
38
+ this . output . content = `` ;
39
+ this . output . writeCount = 0 ;
40
+ }
41
+
30
42
private storage : ConnectionStorage ;
31
43
private emitter : vscode . EventEmitter < IBMiEvent > = new vscode . EventEmitter ( ) ;
32
44
private subscribers : Map < IBMiEvent , SubscriptionMap > = new Map ;
@@ -45,9 +57,14 @@ export default class Instance {
45
57
connect ( options : ConnectionOptions ) : Promise < ConnectionResult > {
46
58
const connection = new IBMi ( ) ;
47
59
48
- this . outputChannel . clear ( ) ;
60
+ this . resetOutput ( ) ;
49
61
connection . appendOutput = ( message ) => {
50
- this . outputChannel . append ( message ) ;
62
+ if ( this . output . writeCount > 150 ) {
63
+ this . resetOutput ( ) ;
64
+ }
65
+
66
+ this . output . channel . append ( message ) ;
67
+ this . output . writeCount ++ ;
51
68
}
52
69
53
70
let result : ConnectionResult ;
@@ -62,13 +79,12 @@ export default class Instance {
62
79
let reconnect = choice === `Yes` ;
63
80
let collectLogs = choice === `No, get logs` ;
64
81
65
- // TODO: how to get output channel stuff?
66
- // if (collectLogs) {
67
- // const logs = conn.getOutputChannelContent();
68
- // vscode.workspace.openTextDocument({ content: logs, language: `plaintext` }).then(doc => {
69
- // vscode.window.showTextDocument(doc);
70
- // });
71
- // }
82
+ if ( collectLogs ) {
83
+ const logs = this . output . content ;
84
+ vscode . workspace . openTextDocument ( { content : logs , language : `plaintext` } ) . then ( doc => {
85
+ vscode . window . showTextDocument ( doc ) ;
86
+ } ) ;
87
+ }
72
88
73
89
this . disconnect ( ) ;
74
90
0 commit comments