Skip to content

Commit 2f5dbcb

Browse files
committed
fix test errors with diagnostics.ts
1 parent c7921c9 commit 2f5dbcb

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

packages/jupyterlab-lsp/src/editor_integration/codemirror.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export abstract class CodeMirrorIntegration
134134
this.adapter = options.adapter;
135135
this.console = this.adapter.console.scope(options.feature.name);
136136
this.trans = options.trans;
137-
137+
138138
this.editor_handlers = new Map();
139139
this.connection_handlers = new Map();
140140
this.wrapper_handlers = new Map();

packages/jupyterlab-lsp/src/features/diagnostics/diagnostics.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ function escapeRegExp(string: string) {
4646
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&');
4747
}
4848

49-
let trans: TranslationBundle;
50-
5149
class DiagnosticsPanel {
5250
private _content: DiagnosticsListing = null;
5351
private _widget: MainAreaWidget<DiagnosticsListing> = null;
5452
feature: DiagnosticsCM;
5553
is_registered = false;
54+
trans: TranslationBundle;
5655

5756
get widget() {
5857
if (this._widget == null || this._widget.content.model == null) {
@@ -69,12 +68,14 @@ class DiagnosticsPanel {
6968
}
7069

7170
protected init_widget() {
72-
this._content = new DiagnosticsListing(new DiagnosticsListing.Model(trans));
71+
this._content = new DiagnosticsListing(
72+
new DiagnosticsListing.Model(this.trans)
73+
);
7374
this._content.model.diagnostics = new DiagnosticsDatabase();
7475
this._content.addClass('lsp-diagnostics-panel-content');
7576
const widget = new MainAreaWidget({ content: this._content });
7677
widget.id = 'lsp-diagnostics-panel';
77-
widget.title.label = trans.__('Diagnostics Panel');
78+
widget.title.label = this.trans?.__('Diagnostics Panel');
7879
widget.title.closable = true;
7980
widget.title.icon = diagnosticsIcon;
8081
return widget;
@@ -102,7 +103,7 @@ class DiagnosticsPanel {
102103

103104
/** Columns Menu **/
104105
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');
106107

107108
app.commands.addCommand(CMD_COLUMN_VISIBILITY, {
108109
execute: args => {
@@ -131,7 +132,7 @@ class DiagnosticsPanel {
131132

132133
/** Diagnostics Menu **/
133134
let ignore_diagnostics_menu = new Menu({ commands: app.commands });
134-
ignore_diagnostics_menu.title.label = trans.__(
135+
ignore_diagnostics_menu.title.label = this.trans.__(
135136
'Ignore diagnostics like this'
136137
);
137138

@@ -175,7 +176,10 @@ class DiagnosticsPanel {
175176
return '';
176177
}
177178
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+
);
179183
}
180184
});
181185
app.commands.addCommand(CMD_IGNORE_DIAGNOSTIC_MSG, {
@@ -204,7 +208,7 @@ class DiagnosticsPanel {
204208
return '';
205209
}
206210
const diagnostic = row.data.diagnostic;
207-
return trans.__(
211+
return this.trans.__(
208212
'Ignore diagnostics with "%1" message',
209213
diagnostic.message
210214
);
@@ -216,7 +220,7 @@ class DiagnosticsPanel {
216220
const row = get_row();
217221
this.widget.content.jump_to(row);
218222
},
219-
label: trans.__('Jump to location'),
223+
label: this.trans.__('Jump to location'),
220224
icon: jumpToIcon
221225
});
222226

@@ -231,22 +235,22 @@ class DiagnosticsPanel {
231235
.writeText(message)
232236
.then(() => {
233237
this.content.model.status_message.set(
234-
trans.__(`Successfully copied "%1" to clipboard`, message)
238+
this.trans.__(`Successfully copied "%1" to clipboard`, message)
235239
);
236240
})
237241
.catch(() => {
238242
console.warn(
239243
'Could not copy with clipboard.writeText interface, falling back'
240244
);
241245
window.prompt(
242-
trans.__(
246+
this.trans.__(
243247
'Your browser protects clipboard from write operations; please copy the message manually'
244248
),
245249
message
246250
);
247251
});
248252
},
249-
label: trans.__("Copy diagnostics' message"),
253+
label: this.trans.__("Copy diagnostics' message"),
250254
icon: copyIcon
251255
});
252256

@@ -321,7 +325,7 @@ export class DiagnosticsCM extends CodeMirrorIntegration {
321325
}
322326

323327
switchDiagnosticsPanelSource = () => {
324-
trans = this.adapter.trans;
328+
diagnostics_panel.trans = this.adapter.trans;
325329
if (
326330
diagnostics_panel.content.model.virtual_editor === this.virtual_editor &&
327331
diagnostics_panel.content.model.diagnostics == this.diagnostics_db

0 commit comments

Comments
 (0)