From 9628fab4f8ed5eaf9facefcc98801cc5034d66c2 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Tue, 23 Aug 2022 15:23:48 +0200 Subject: [PATCH] Fixes edge case (#158888) --- .../contrib/mergeEditor/browser/model/mergeEditorModel.ts | 4 ++++ .../contrib/mergeEditor/browser/model/modifiedBaseRange.ts | 1 - .../mergeEditor/browser/view/editors/inputCodeEditorView.ts | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.ts b/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.ts index dfa963e6ac5..c165e579157 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.ts @@ -334,6 +334,10 @@ export class MergeEditorModel extends EditorModel { return ModifiedBaseRangeState.conflicting; } + public has(baseRange: ModifiedBaseRange): boolean { + return this.modifiedBaseRangeHandlingStateStores.get().has(baseRange); + } + public isHandled(baseRange: ModifiedBaseRange): IObservable { return this.modifiedBaseRangeHandlingStateStores.get().get(baseRange)!; } diff --git a/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.ts b/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.ts index 2e6b6031382..e018e313e19 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.ts @@ -48,7 +48,6 @@ export class ModifiedBaseRange { public readonly input1CombinedDiff = DetailedLineRangeMapping.join(this.input1Diffs); public readonly input2CombinedDiff = DetailedLineRangeMapping.join(this.input2Diffs); - constructor( public readonly baseRange: LineRange, public readonly baseTextModel: ITextModel, diff --git a/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.ts b/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.ts index ae5d97340e8..99c7ca7e93f 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.ts @@ -131,6 +131,9 @@ export class InputCodeEditorView extends CodeEditorView { className: derived('checkbox classnames', (reader) => { const classNames = []; const active = viewModel.activeModifiedBaseRange.read(reader); + if (!model.has(baseRange)) { + return ''; // Invalid state, should only be observed temporarily + } const isHandled = model.isHandled(baseRange).read(reader); if (isHandled) { classNames.push('handled');