Skip to content

Commit 2863766

Browse files
authored
Merge pull request microsoft#199036 from microsoft/hediet/b/systematic-rabbit
Fixes microsoft#198832
2 parents eb56719 + 48e7527 commit 2863766

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { LazyStatefulPromise, raceTimeout } from 'vs/base/common/async';
7+
import { onUnexpectedError } from 'vs/base/common/errors';
78
import { IDisposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
89
import { deepClone } from 'vs/base/common/objects';
9-
import { isObject } from 'vs/base/common/types';
10+
import { isDefined, isObject } from 'vs/base/common/types';
1011
import { URI } from 'vs/base/common/uri';
1112
import { ConstLazyPromise, IDocumentDiffItem, IMultiDiffEditorModel } from 'vs/editor/browser/widget/multiDiffEditorWidget/model';
1213
import { MultiDiffEditorViewModel } from 'vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel';
@@ -21,6 +22,7 @@ import { DEFAULT_EDITOR_ASSOCIATION, EditorInputCapabilities } from 'vs/workbenc
2122
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
2223
import { ILanguageSupport } from 'vs/workbench/services/textfile/common/textfiles';
2324

25+
/* hot-reload:patch-prototype-methods */
2426
export class MultiDiffEditorInput extends EditorInput implements ILanguageSupport {
2527
static readonly ID: string = 'workbench.input.multiDiffEditor';
2628

@@ -83,13 +85,22 @@ export class MultiDiffEditorInput extends EditorInput implements ILanguageSuppor
8385

8486
private async _createModel(): Promise<IMultiDiffEditorModel & IDisposable> {
8587
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);
93104

94105
const textResourceConfigurationService = this._textResourceConfigurationService;
95106

0 commit comments

Comments
 (0)