@@ -21,24 +21,29 @@ import { VirtualEditor } from '../../../virtual/editor';
2121const default_severity = 2 ;
2222
2323class DiagnosticsPanel {
24- content : DiagnosticsListing ;
25- widget : MainAreaWidget < DiagnosticsListing > ;
24+ private _content : DiagnosticsListing = null ;
25+ private _widget : MainAreaWidget < DiagnosticsListing > = null ;
2626 is_registered = false ;
2727
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 ;
3536 }
3637
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 } ) ;
4247 widget . id = 'lsp-diagnostics-panel' ;
4348 widget . title . label = 'Diagnostics Panel' ;
4449 widget . title . closable = true ;
@@ -68,7 +73,7 @@ export class Diagnostics extends CodeMirrorLSPFeature {
6873 static commands : Array < IFeatureCommand > = [
6974 {
7075 id : 'show-diagnostics-panel' ,
71- execute : ( { app, features } ) => {
76+ execute : ( { app, features, adapter } ) => {
7277 let diagnostics_feature = features . get ( 'Diagnostics' ) as Diagnostics ;
7378 diagnostics_feature . switchDiagnosticsPanelSource ( ) ;
7479
@@ -113,7 +118,11 @@ export class Diagnostics extends CodeMirrorLSPFeature {
113118 }
114119
115120 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+ } ) ;
117126 }
118127 app . shell . activateById ( panel_widget . id ) ;
119128 } ,
0 commit comments