@@ -12,28 +12,34 @@ export function wrapCompleters(completers, cutoff = 100) {
1212 let ori = completer . getCompletions
1313 completer . getCompletions = function ( editor , session , pos , prefix , callback ) {
1414 let startTime = Date . now ( )
15- ori ( editor , session , pos , prefix , ( ...args ) => {
16- let msElapsed = Date . now ( ) - startTime
17- lastSpeeds [ i ] = msElapsed
15+ try {
16+ ori ( editor , session , pos , prefix , ( ...args ) => {
17+ let msElapsed = Date . now ( ) - startTime
18+ lastSpeeds [ i ] = msElapsed
1819
19- if ( isLiveCompletionDisabled && isPerformant ( ) ) {
20- console . warn ( "Manual autocomplete was performant - re-enabling live autocomplete" )
21- editor . setOptions ( {
22- enableLiveAutocompletion : true
23- } )
24- isLiveCompletionDisabled = false
25- }
20+ if ( isLiveCompletionDisabled && isPerformant ( ) ) {
21+ console . warn ( "Manual autocomplete was performant - re-enabling live autocomplete" )
22+ editor . setOptions ( {
23+ enableLiveAutocompletion : true
24+ } )
25+ isLiveCompletionDisabled = false
26+ }
2627
27- if ( msElapsed > cutoff && editor . getOption ( "enableLiveAutocompletion" ) ) {
28- console . warn ( "Live autocomplete is slow - disabling it" )
29- editor . setOptions ( {
30- enableLiveAutocompletion : false
31- } )
32- isLiveCompletionDisabled = true
33- }
28+ if ( msElapsed > cutoff && editor . getOption ( "enableLiveAutocompletion" ) ) {
29+ console . warn ( "Live autocomplete is slow - disabling it" )
30+ editor . setOptions ( {
31+ enableLiveAutocompletion : false
32+ } )
33+ isLiveCompletionDisabled = true
34+ }
3435
35- callback ( ...args )
36- } )
36+ callback ( ...args )
37+ } )
38+ } catch ( e ) {
39+ console . error ( "Autocompleter encountered an error" )
40+ console . error ( e )
41+ callback ( null , [ ] )
42+ }
3743 }
3844 return completer
3945 } )
0 commit comments