@@ -21,7 +21,7 @@ import { regExpFlags } from 'vs/base/common/strings';
21
21
import { isNonEmptyArray } from 'vs/base/common/arrays' ;
22
22
import { ILogService } from 'vs/platform/log/common/log' ;
23
23
import { StopWatch } from 'vs/base/common/stopwatch' ;
24
- import { canceled } from 'vs/base/common/errors' ;
24
+ import { canceled , onUnexpectedError } from 'vs/base/common/errors' ;
25
25
import { UnicodeHighlighterOptions } from 'vs/editor/common/services/unicodeTextModelHighlighter' ;
26
26
import { IEditorWorkerHost } from 'vs/editor/common/services/editorWorkerHost' ;
27
27
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures' ;
@@ -153,7 +153,11 @@ export class EditorWorkerService extends Disposable implements IEditorWorkerServ
153
153
return Promise . resolve ( edits ) ; // File too large
154
154
}
155
155
const sw = StopWatch . create ( true ) ;
156
- const result = this . _workerManager . withWorker ( ) . then ( client => client . computeHumanReadableDiff ( resource , edits ) ) ;
156
+ const result = this . _workerManager . withWorker ( ) . then ( client => client . computeHumanReadableDiff ( resource , edits ) ) . catch ( ( err ) => {
157
+ onUnexpectedError ( err ) ;
158
+ // In case of an exception, fall back to computeMoreMinimalEdits
159
+ return this . computeMoreMinimalEdits ( resource , edits , true ) ;
160
+ } ) ;
157
161
result . finally ( ( ) => this . _logService . trace ( 'FORMAT#computeHumanReadableDiff' , resource . toString ( true ) , sw . elapsed ( ) ) ) ;
158
162
return Promise . race ( [ result , timeout ( 1000 ) . then ( ( ) => edits ) ] ) ;
159
163
0 commit comments