File tree Expand file tree Collapse file tree 7 files changed +34
-13
lines changed
adapters/codemirror/features Expand file tree Collapse file tree 7 files changed +34
-13
lines changed Original file line number Diff line number Diff line change 11## CHANGELOG
22
3+ ### ` @krassowski/jupyterlab-lsp 1.1.1 ` (unreleased)
4+
5+ - bug fixes
6+
7+ - emits console warnings instead of throwing errors in hover handlers and connections ([ #299 ] [ ] , [ #300 ] [ ] )
8+
9+ [ #299 ] : https://github.com/krassowski/jupyterlab-lsp/pull/299
10+ [ #300 ] : https://github.com/krassowski/jupyterlab-lsp/pull/300
11+
312### ` jupyter-lsp 0.9.x ` (unreleased)
413
514- autodetects the ` texlab ` language server for ` .tex ` files ([ #288 ] [ ] )
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ export class Hover extends CodeMirrorLSPFeature {
201201 e . message === "Cannot read property 'string' of undefined"
202202 )
203203 ) {
204- throw e ;
204+ console . warn ( e ) ;
205205 }
206206 }
207207 } ;
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ export class NotebookCommandManager extends ContextCommandManager {
201201 return notebook_adapters . get ( notebook . id ) ;
202202 }
203203
204- context_from_active_document ( ) : ICommandContext {
204+ context_from_active_document ( ) : ICommandContext | null {
205205 if ( ! this . is_widget_current ) {
206206 return null ;
207207 }
@@ -213,7 +213,7 @@ export class NotebookCommandManager extends ContextCommandManager {
213213
214214 let virtual_editor = this . current_adapter ?. virtual_editor ;
215215
216- if ( ! virtual_editor ) {
216+ if ( virtual_editor == null ) {
217217 return null ;
218218 }
219219
@@ -222,6 +222,11 @@ export class NotebookCommandManager extends ContextCommandManager {
222222 cm_cursor
223223 ) ;
224224
225+ if ( root_position == null ) {
226+ console . warn ( 'Could not retrieve current context' , virtual_editor ) ;
227+ return null ;
228+ }
229+
225230 return this . current_adapter ?. get_context ( root_position ) ;
226231 }
227232}
Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ export class LanguageServerManager implements ILanguageServerManager {
5353 ) ;
5454
5555 if ( ! response . ok ) {
56- throw new Error ( response . statusText ) ;
56+ console . error ( 'Could not fetch sessions' , response ) ;
57+ return ;
5758 }
5859
5960 let sessions : SCHEMA . Sessions ;
Original file line number Diff line number Diff line change @@ -118,11 +118,12 @@ export class VirtualEditorForNotebook extends VirtualEditor {
118118 transform_from_notebook_to_root (
119119 cell : Cell ,
120120 position : IEditorPosition
121- ) : IRootPosition {
121+ ) : IRootPosition | null {
122122 // TODO: if cell is not known, refresh
123123 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 ;
126127 }
127128 return {
128129 ...( position as CodeMirror . Position ) ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ interface IFlexibleServerCapabilities extends ServerCapabilities {
1111function registerServerCapability (
1212 serverCapabilities : ServerCapabilities ,
1313 registration : Registration
14- ) : ServerCapabilities {
14+ ) : ServerCapabilities | null {
1515 const serverCapabilitiesCopy = JSON . parse (
1616 JSON . stringify ( serverCapabilities )
1717 ) as IFlexibleServerCapabilities ;
@@ -27,7 +27,8 @@ function registerServerCapability(
2727 ) ;
2828 }
2929 } else {
30- throw new Error ( 'Could not register server capability.' ) ;
30+ console . warn ( 'Could not register server capability.' , registration ) ;
31+ return null ;
3132 }
3233
3334 return serverCapabilitiesCopy ;
Original file line number Diff line number Diff line change @@ -79,10 +79,14 @@ export class LspWsConnection extends events.EventEmitter
7979 ( params : protocol . RegistrationParams ) => {
8080 params . registrations . forEach (
8181 ( 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+ }
8690 }
8791 ) ;
8892
You can’t perform that action at this time.
0 commit comments