Skip to content

Commit a6dee4c

Browse files
committed
Strict null check textDiffEditor
1 parent 873b17f commit a6dee4c

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/tsconfig.strictNullChecks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
"./vs/workbench/browser/parts/editor/rangeDecorations.ts",
117117
"./vs/workbench/browser/parts/editor/resourceViewer.ts",
118118
"./vs/workbench/browser/parts/editor/sideBySideEditor.ts",
119+
"./vs/workbench/browser/parts/editor/textDiffEditor.ts",
119120
"./vs/workbench/browser/parts/editor/textEditor.ts",
120121
"./vs/workbench/browser/parts/editor/textResourceEditor.ts",
121122
"./vs/workbench/browser/parts/quickinput/quickInputBox.ts",

src/vs/editor/common/editorCommon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ export interface IDiffEditor extends IEditor {
469469
/**
470470
* Type the getModel() of IEditor.
471471
*/
472-
getModel(): IDiffEditorModel;
472+
getModel(): IDiffEditorModel | null;
473473

474474
/**
475475
* Get the `original` editor.

src/vs/workbench/browser/parts/editor/textDiffEditor.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
6161
return new EditorMemento(this.getId(), key, Object.create(null), limit, editorGroupService); // do not persist in storage as diff editors are never persisted
6262
}
6363

64-
getTitle(): string {
64+
getTitle(): string | null {
6565
if (this.input) {
6666
return this.input.getName();
6767
}
@@ -120,6 +120,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
120120

121121
// Readonly flag
122122
diffEditor.updateOptions({ readOnly: resolvedDiffEditorModel.isReadonly() });
123+
return undefined;
123124
}, error => {
124125

125126
// In case we tried to open a file and the response indicates that this is not a text file, fallback to binary diff.
@@ -262,7 +263,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
262263
return super.loadTextEditorViewState(resource) as IDiffEditorViewState; // overridden for text diff editor support
263264
}
264265

265-
private saveTextDiffEditorViewState(input: EditorInput): void {
266+
private saveTextDiffEditorViewState(input: EditorInput | null): void {
266267
if (!(input instanceof DiffEditorInput)) {
267268
return; // only supported for diff editor inputs
268269
}
@@ -288,11 +289,11 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
288289
}
289290
}
290291

291-
protected retrieveTextEditorViewState(resource: URI): IDiffEditorViewState {
292+
protected retrieveTextEditorViewState(resource: URI): IDiffEditorViewState | null {
292293
return this.retrieveTextDiffEditorViewState(resource); // overridden for text diff editor support
293294
}
294295

295-
private retrieveTextDiffEditorViewState(resource: URI): IDiffEditorViewState {
296+
private retrieveTextDiffEditorViewState(resource: URI): IDiffEditorViewState | null {
296297
const control = this.getControl();
297298
const model = control.getModel();
298299
if (!model || !model.modified || !model.original) {
@@ -311,9 +312,9 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
311312
return control.saveViewState();
312313
}
313314

314-
private toDiffEditorViewStateResource(modelOrInput: IDiffEditorModel | DiffEditorInput): URI {
315-
let original: URI;
316-
let modified: URI;
315+
private toDiffEditorViewStateResource(modelOrInput: IDiffEditorModel | DiffEditorInput): URI | null {
316+
let original: URI | null;
317+
let modified: URI | null;
317318

318319
if (modelOrInput instanceof DiffEditorInput) {
319320
original = modelOrInput.originalInput.getResource();

0 commit comments

Comments
 (0)