File tree Expand file tree Collapse file tree 7 files changed +32
-17
lines changed
adapters/codemirror/features Expand file tree Collapse file tree 7 files changed +32
-17
lines changed Original file line number Diff line number Diff line change 8
8
},
9
9
"outputs" : [],
10
10
"source" : [
11
- " from markdown import markdown\n " ,
12
11
" import sys\n " ,
13
- " sys.path.insert(0, '..')\n " ,
12
+ " \n " ,
13
+ " from markdown import markdown\n " ,
14
+ " \n " ,
14
15
" from versions import (\n " ,
15
16
" JUPYTER_LSP_VERSION,\n " ,
16
17
" JUPYTERLAB_LSP_VERSION,\n " ,
17
18
" JUPYTERLAB_NEXT_MAJOR_VERSION,\n " ,
18
19
" JUPYTERLAB_VERSION,\n " ,
19
- " REQUIRED_JUPYTERLAB\n " ,
20
- " )"
20
+ " REQUIRED_JUPYTERLAB,\n " ,
21
+ " )\n " ,
22
+ " \n " ,
23
+ " sys.path.insert(0, \" ..\" )"
21
24
]
22
25
},
23
26
{
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ export class Hover extends CodeMirrorLSPFeature {
201
201
e . message === "Cannot read property 'string' of undefined"
202
202
)
203
203
) {
204
- throw e ;
204
+ console . warn ( e ) ;
205
205
}
206
206
}
207
207
} ;
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ export class NotebookCommandManager extends ContextCommandManager {
201
201
return notebook_adapters . get ( notebook . id ) ;
202
202
}
203
203
204
- context_from_active_document ( ) : ICommandContext {
204
+ context_from_active_document ( ) : ICommandContext | null {
205
205
if ( ! this . is_widget_current ) {
206
206
return null ;
207
207
}
@@ -213,7 +213,7 @@ export class NotebookCommandManager extends ContextCommandManager {
213
213
214
214
let virtual_editor = this . current_adapter ?. virtual_editor ;
215
215
216
- if ( ! virtual_editor ) {
216
+ if ( virtual_editor == null ) {
217
217
return null ;
218
218
}
219
219
@@ -222,6 +222,11 @@ export class NotebookCommandManager extends ContextCommandManager {
222
222
cm_cursor
223
223
) ;
224
224
225
+ if ( root_position == null ) {
226
+ console . warn ( 'Could not retrieve current context' , virtual_editor ) ;
227
+ return null ;
228
+ }
229
+
225
230
return this . current_adapter ?. get_context ( root_position ) ;
226
231
}
227
232
}
Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ export class LanguageServerManager implements ILanguageServerManager {
53
53
) ;
54
54
55
55
if ( ! response . ok ) {
56
- throw new Error ( response . statusText ) ;
56
+ console . error ( 'Could not fetch sessions' , response ) ;
57
+ return ;
57
58
}
58
59
59
60
let sessions : SCHEMA . Sessions ;
Original file line number Diff line number Diff line change @@ -118,11 +118,12 @@ export class VirtualEditorForNotebook extends VirtualEditor {
118
118
transform_from_notebook_to_root (
119
119
cell : Cell ,
120
120
position : IEditorPosition
121
- ) : IRootPosition {
121
+ ) : IRootPosition | null {
122
122
// TODO: if cell is not known, refresh
123
123
let shift = this . cell_to_corresponding_source_line . get ( cell ) ;
124
- if ( shift === undefined ) {
125
- throw Error ( 'Cell not found in cell_line_map' ) ;
124
+ if ( shift == null ) {
125
+ console . warn ( 'Cell not found in cell_line_map' ) ;
126
+ return null ;
126
127
}
127
128
return {
128
129
...( position as CodeMirror . Position ) ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ interface IFlexibleServerCapabilities extends ServerCapabilities {
11
11
function registerServerCapability (
12
12
serverCapabilities : ServerCapabilities ,
13
13
registration : Registration
14
- ) : ServerCapabilities {
14
+ ) : ServerCapabilities | null {
15
15
const serverCapabilitiesCopy = JSON . parse (
16
16
JSON . stringify ( serverCapabilities )
17
17
) as IFlexibleServerCapabilities ;
@@ -27,7 +27,8 @@ function registerServerCapability(
27
27
) ;
28
28
}
29
29
} else {
30
- throw new Error ( 'Could not register server capability.' ) ;
30
+ console . warn ( 'Could not register server capability.' , registration ) ;
31
+ return null ;
31
32
}
32
33
33
34
return serverCapabilitiesCopy ;
Original file line number Diff line number Diff line change @@ -79,10 +79,14 @@ export class LspWsConnection extends events.EventEmitter
79
79
( params : protocol . RegistrationParams ) => {
80
80
params . registrations . forEach (
81
81
( capabilityRegistration : protocol . Registration ) => {
82
- this . serverCapabilities = registerServerCapability (
83
- this . serverCapabilities ,
84
- capabilityRegistration
85
- ) ;
82
+ try {
83
+ this . serverCapabilities = registerServerCapability (
84
+ this . serverCapabilities ,
85
+ capabilityRegistration
86
+ ) ;
87
+ } catch ( err ) {
88
+ console . error ( err ) ;
89
+ }
86
90
}
87
91
) ;
88
92
You can’t perform that action at this time.
0 commit comments