Skip to content

Commit 9204cd8

Browse files
authored
testing: fix error hovering with no coverage open (microsoft#202591)
Fixes microsoft#202564
1 parent c9127a6 commit 9204cd8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ export class CodeCoverageDecorations extends Disposable implements IEditorContri
105105
}));
106106

107107
this._register(editor.onMouseMove(e => {
108-
if (e.target.type === MouseTargetType.GUTTER_LINE_NUMBERS) {
108+
const model = editor.getModel();
109+
if (e.target.type === MouseTargetType.GUTTER_LINE_NUMBERS && model) {
109110
this.hoverLineNumber(editor.getModel()!, e.target.position.lineNumber);
110111
} else if (this.lineHoverWidget.hasValue && this.lineHoverWidget.value.getDomNode().contains(e.target.element)) {
111112
// don't dismiss the hover
112-
} else if (CodeCoverageDecorations.showInline.get() && e.target.type === MouseTargetType.CONTENT_TEXT) {
113-
this.hoverInlineDecoration(editor.getModel()!, e.target.position);
113+
} else if (CodeCoverageDecorations.showInline.get() && e.target.type === MouseTargetType.CONTENT_TEXT && model) {
114+
this.hoverInlineDecoration(model, e.target.position);
114115
} else {
115116
this.hoveredStore.clear();
116117
}
@@ -168,7 +169,7 @@ export class CodeCoverageDecorations extends Disposable implements IEditorContri
168169
}
169170

170171
private hoverLineNumber(model: ITextModel, lineNumber: number) {
171-
if (lineNumber === this.hoveredSubject) {
172+
if (lineNumber === this.hoveredSubject || !this.details) {
172173
return;
173174
}
174175

@@ -208,7 +209,7 @@ export class CodeCoverageDecorations extends Disposable implements IEditorContri
208209
});
209210
}
210211

211-
this.lineHoverWidget.value.startShowingAt(lineNumber, this.details!, wasPreviouslyHovering);
212+
this.lineHoverWidget.value.startShowingAt(lineNumber, this.details, wasPreviouslyHovering);
212213

213214
this.hoveredStore.add(this.editor.onMouseLeave(() => {
214215
this.hoveredStore.clear();

0 commit comments

Comments
 (0)