4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import { LazyStatefulPromise , raceTimeout } from 'vs/base/common/async' ;
7
+ import { onUnexpectedError } from 'vs/base/common/errors' ;
7
8
import { IDisposable , DisposableStore , toDisposable } from 'vs/base/common/lifecycle' ;
8
9
import { deepClone } from 'vs/base/common/objects' ;
9
- import { isObject } from 'vs/base/common/types' ;
10
+ import { isDefined , isObject } from 'vs/base/common/types' ;
10
11
import { URI } from 'vs/base/common/uri' ;
11
12
import { ConstLazyPromise , IDocumentDiffItem , IMultiDiffEditorModel } from 'vs/editor/browser/widget/multiDiffEditorWidget/model' ;
12
13
import { MultiDiffEditorViewModel } from 'vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel' ;
@@ -21,6 +22,7 @@ import { DEFAULT_EDITOR_ASSOCIATION, EditorInputCapabilities } from 'vs/workbenc
21
22
import { EditorInput } from 'vs/workbench/common/editor/editorInput' ;
22
23
import { ILanguageSupport } from 'vs/workbench/services/textfile/common/textfiles' ;
23
24
25
+ /* hot-reload:patch-prototype-methods */
24
26
export class MultiDiffEditorInput extends EditorInput implements ILanguageSupport {
25
27
static readonly ID : string = 'workbench.input.multiDiffEditor' ;
26
28
@@ -83,13 +85,22 @@ export class MultiDiffEditorInput extends EditorInput implements ILanguageSuppor
83
85
84
86
private async _createModel ( ) : Promise < IMultiDiffEditorModel & IDisposable > {
85
87
const store = new DisposableStore ( ) ;
86
- const rs = await Promise . all ( this . resources . map ( async r => ( {
87
- originalRef : r . original ? store . add ( await this . _textModelService . createModelReference ( r . original ) ) : undefined ,
88
- originalModel : ! r . original ? store . add ( this . _modelService . createModel ( '' , null ) ) : undefined ,
89
- modifiedRef : r . modified ? store . add ( await this . _textModelService . createModelReference ( r . modified ) ) : undefined ,
90
- modifiedModel : ! r . modified ? store . add ( this . _modelService . createModel ( '' , null ) ) : undefined ,
91
- title : r . resource . fsPath ,
92
- } ) ) ) ;
88
+ const rs = ( await Promise . all ( this . resources . map ( async r => {
89
+ try {
90
+ return {
91
+ originalRef : r . original ? store . add ( await this . _textModelService . createModelReference ( r . original ) ) : undefined ,
92
+ originalModel : ! r . original ? store . add ( this . _modelService . createModel ( '' , null ) ) : undefined ,
93
+ modifiedRef : r . modified ? store . add ( await this . _textModelService . createModelReference ( r . modified ) ) : undefined ,
94
+ modifiedModel : ! r . modified ? store . add ( this . _modelService . createModel ( '' , null ) ) : undefined ,
95
+ title : r . resource . fsPath ,
96
+ } ;
97
+ } catch ( e ) {
98
+ // e.g. "File seems to be binary and cannot be opened as text"
99
+ console . error ( e ) ;
100
+ onUnexpectedError ( e ) ;
101
+ return undefined ;
102
+ }
103
+ } ) ) ) . filter ( isDefined ) ;
93
104
94
105
const textResourceConfigurationService = this . _textResourceConfigurationService ;
95
106
0 commit comments