@@ -46,13 +46,12 @@ function escapeRegExp(string: string) {
46
46
return string . replace ( / [ . * + \- ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
47
47
}
48
48
49
- let trans : TranslationBundle ;
50
-
51
49
class DiagnosticsPanel {
52
50
private _content : DiagnosticsListing = null ;
53
51
private _widget : MainAreaWidget < DiagnosticsListing > = null ;
54
52
feature : DiagnosticsCM ;
55
53
is_registered = false ;
54
+ trans : TranslationBundle ;
56
55
57
56
get widget ( ) {
58
57
if ( this . _widget == null || this . _widget . content . model == null ) {
@@ -69,12 +68,14 @@ class DiagnosticsPanel {
69
68
}
70
69
71
70
protected init_widget ( ) {
72
- this . _content = new DiagnosticsListing ( new DiagnosticsListing . Model ( trans ) ) ;
71
+ this . _content = new DiagnosticsListing (
72
+ new DiagnosticsListing . Model ( this . trans )
73
+ ) ;
73
74
this . _content . model . diagnostics = new DiagnosticsDatabase ( ) ;
74
75
this . _content . addClass ( 'lsp-diagnostics-panel-content' ) ;
75
76
const widget = new MainAreaWidget ( { content : this . _content } ) ;
76
77
widget . id = 'lsp-diagnostics-panel' ;
77
- widget . title . label = trans . __ ( 'Diagnostics Panel' ) ;
78
+ widget . title . label = this . trans ? .__ ( 'Diagnostics Panel' ) ;
78
79
widget . title . closable = true ;
79
80
widget . title . icon = diagnosticsIcon ;
80
81
return widget ;
@@ -102,7 +103,7 @@ class DiagnosticsPanel {
102
103
103
104
/** Columns Menu **/
104
105
let columns_menu = new Menu ( { commands : app . commands } ) ;
105
- columns_menu . title . label = trans . __ ( 'Panel columns' ) ;
106
+ columns_menu . title . label = this . trans . __ ( 'Panel columns' ) ;
106
107
107
108
app . commands . addCommand ( CMD_COLUMN_VISIBILITY , {
108
109
execute : args => {
@@ -131,7 +132,7 @@ class DiagnosticsPanel {
131
132
132
133
/** Diagnostics Menu **/
133
134
let ignore_diagnostics_menu = new Menu ( { commands : app . commands } ) ;
134
- ignore_diagnostics_menu . title . label = trans . __ (
135
+ ignore_diagnostics_menu . title . label = this . trans . __ (
135
136
'Ignore diagnostics like this'
136
137
) ;
137
138
@@ -175,7 +176,10 @@ class DiagnosticsPanel {
175
176
return '' ;
176
177
}
177
178
const diagnostic = row . data . diagnostic ;
178
- return trans . __ ( `Ignore diagnostics with "%1" code` , diagnostic . code ) ;
179
+ return this . trans . __ (
180
+ 'Ignore diagnostics with "%1" code' ,
181
+ diagnostic . code
182
+ ) ;
179
183
}
180
184
} ) ;
181
185
app . commands . addCommand ( CMD_IGNORE_DIAGNOSTIC_MSG , {
@@ -204,7 +208,7 @@ class DiagnosticsPanel {
204
208
return '' ;
205
209
}
206
210
const diagnostic = row . data . diagnostic ;
207
- return trans . __ (
211
+ return this . trans . __ (
208
212
'Ignore diagnostics with "%1" message' ,
209
213
diagnostic . message
210
214
) ;
@@ -216,7 +220,7 @@ class DiagnosticsPanel {
216
220
const row = get_row ( ) ;
217
221
this . widget . content . jump_to ( row ) ;
218
222
} ,
219
- label : trans . __ ( 'Jump to location' ) ,
223
+ label : this . trans . __ ( 'Jump to location' ) ,
220
224
icon : jumpToIcon
221
225
} ) ;
222
226
@@ -231,22 +235,22 @@ class DiagnosticsPanel {
231
235
. writeText ( message )
232
236
. then ( ( ) => {
233
237
this . content . model . status_message . set (
234
- trans . __ ( `Successfully copied "%1" to clipboard` , message )
238
+ this . trans . __ ( `Successfully copied "%1" to clipboard` , message )
235
239
) ;
236
240
} )
237
241
. catch ( ( ) => {
238
242
console . warn (
239
243
'Could not copy with clipboard.writeText interface, falling back'
240
244
) ;
241
245
window . prompt (
242
- trans . __ (
246
+ this . trans . __ (
243
247
'Your browser protects clipboard from write operations; please copy the message manually'
244
248
) ,
245
249
message
246
250
) ;
247
251
} ) ;
248
252
} ,
249
- label : trans . __ ( "Copy diagnostics' message" ) ,
253
+ label : this . trans . __ ( "Copy diagnostics' message" ) ,
250
254
icon : copyIcon
251
255
} ) ;
252
256
@@ -321,7 +325,7 @@ export class DiagnosticsCM extends CodeMirrorIntegration {
321
325
}
322
326
323
327
switchDiagnosticsPanelSource = ( ) => {
324
- trans = this . adapter . trans ;
328
+ diagnostics_panel . trans = this . adapter . trans ;
325
329
if (
326
330
diagnostics_panel . content . model . virtual_editor === this . virtual_editor &&
327
331
diagnostics_panel . content . model . diagnostics == this . diagnostics_db
0 commit comments