@@ -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 ;
36+ }
37+
38+ get content ( ) {
39+ return this . widget . content ;
3540 }
3641
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 } ) ;
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 ;
0 commit comments