@@ -21,24 +21,29 @@ import { VirtualEditor } from '../../../virtual/editor';
21
21
const default_severity = 2 ;
22
22
23
23
class DiagnosticsPanel {
24
- content : DiagnosticsListing ;
25
- widget : MainAreaWidget < DiagnosticsListing > ;
24
+ private _content : DiagnosticsListing = null ;
25
+ private _widget : MainAreaWidget < DiagnosticsListing > = null ;
26
26
is_registered = false ;
27
27
28
- constructor ( ) {
29
- this . widget = this . init_widget ( ) ;
30
- this . widget . content . disposed . connect ( ( ) => {
31
- // immortal widget (or mild memory leak) TODO: rewrite this
32
- this . widget . dispose ( ) ;
33
- this . widget = this . init_widget ( ) ;
34
- } ) ;
28
+ get widget ( ) {
29
+ if ( this . _widget == null || this . _widget . content . model === null ) {
30
+ if ( this . _widget && ! this . _widget . isDisposed ) {
31
+ this . _widget . dispose ( ) ;
32
+ }
33
+ this . _widget = this . init_widget ( ) ;
34
+ }
35
+ return this . _widget ;
35
36
}
36
37
37
- init_widget ( ) {
38
- this . content = new DiagnosticsListing ( new DiagnosticsListing . Model ( ) ) ;
39
- this . content . model . diagnostics = new DiagnosticsDatabase ( ) ;
40
- this . content . addClass ( 'lsp-diagnostics-panel-content' ) ;
41
- const widget = new MainAreaWidget ( { content : this . content } ) ;
38
+ get content ( ) {
39
+ return this . widget . content ;
40
+ }
41
+
42
+ protected init_widget ( ) {
43
+ this . _content = new DiagnosticsListing ( new DiagnosticsListing . Model ( ) ) ;
44
+ this . _content . model . diagnostics = new DiagnosticsDatabase ( ) ;
45
+ this . _content . addClass ( 'lsp-diagnostics-panel-content' ) ;
46
+ const widget = new MainAreaWidget ( { content : this . _content } ) ;
42
47
widget . id = 'lsp-diagnostics-panel' ;
43
48
widget . title . label = 'Diagnostics Panel' ;
44
49
widget . title . closable = true ;
@@ -68,7 +73,7 @@ export class Diagnostics extends CodeMirrorLSPFeature {
68
73
static commands : Array < IFeatureCommand > = [
69
74
{
70
75
id : 'show-diagnostics-panel' ,
71
- execute : ( { app, features } ) => {
76
+ execute : ( { app, features, adapter } ) => {
72
77
let diagnostics_feature = features . get ( 'Diagnostics' ) as Diagnostics ;
73
78
diagnostics_feature . switchDiagnosticsPanelSource ( ) ;
74
79
@@ -113,7 +118,11 @@ export class Diagnostics extends CodeMirrorLSPFeature {
113
118
}
114
119
115
120
if ( ! panel_widget . isAttached ) {
116
- app . shell . add ( panel_widget , 'main' ) ;
121
+ console . warn ( adapter . widget_id ) ;
122
+ app . shell . add ( panel_widget , 'main' , {
123
+ ref : adapter . widget_id ,
124
+ mode : 'split-bottom'
125
+ } ) ;
117
126
}
118
127
app . shell . activateById ( panel_widget . id ) ;
119
128
} ,
0 commit comments