-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Fixes #16860: Improving exception experience #20807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fa311f5
e185352
a6f4fc7
e000dbb
2bda83c
2480d63
0a53abb
873c090
7e35467
2e7af33
706773b
87eed20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ | |
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good |
||
|
||
.monaco-editor .zone-widget-arrow.below { | ||
border-bottom-color: yellowGreen; | ||
border-bottom-color: rgb(0, 122, 204); | ||
} | ||
|
||
.monaco-editor .zone-widget .zone-widget-container { | ||
border-top-style: solid; | ||
border-bottom-style: solid; | ||
border-top-width: 0; | ||
border-bottom-width: 0; | ||
border-top-color: yellowGreen; | ||
border-bottom-color: yellowGreen; | ||
border-top-color: rgb(0, 122, 204); | ||
border-bottom-color: rgb(0, 122, 204); | ||
position: relative; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, IViewZone, IViewZo | |
export interface IOptions { | ||
showFrame?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure that references widget, peek view widget, error list widget and breakpoint widget are rendered the same as before. |
||
showArrow?: boolean; | ||
frameColor?: string; | ||
frameWidth?: number; | ||
className?: string; | ||
isAccessible?: boolean; | ||
|
@@ -28,7 +27,6 @@ export interface IOptions { | |
const defaultOptions: IOptions = { | ||
showArrow: true, | ||
showFrame: true, | ||
frameColor: '', | ||
className: '' | ||
}; | ||
|
||
|
@@ -103,6 +101,7 @@ export abstract class ZoneWidget extends Widget implements IHorizontalSashLayout | |
public domNode: HTMLElement; | ||
public editor: ICodeEditor; | ||
public options: IOptions; | ||
private arrow: HTMLElement = null; | ||
|
||
constructor(editor: ICodeEditor, options: IOptions = {}) { | ||
super(); | ||
|
@@ -148,8 +147,12 @@ export abstract class ZoneWidget extends Widget implements IHorizontalSashLayout | |
this.container = document.createElement('div'); | ||
dom.addClass(this.container, 'zone-widget-container'); | ||
this.domNode.appendChild(this.container); | ||
this._fillContainer(this.container); | ||
if (this.options.showArrow) { | ||
this.arrow = document.createElement('div'); | ||
this.arrow.className = 'zone-widget-arrow below'; | ||
} | ||
|
||
this._fillContainer(this.container); | ||
this._initSash(); | ||
} | ||
|
||
|
@@ -232,22 +235,17 @@ export abstract class ZoneWidget extends Widget implements IHorizontalSashLayout | |
|
||
// Render the widget as zone (rendering) and widget (lifecycle) | ||
let viewZoneDomNode = document.createElement('div'), | ||
arrow = document.createElement('div'), | ||
lineHeight = this.editor.getConfiguration().lineHeight, | ||
arrowHeight = 0, frameThickness = 0; | ||
|
||
// Render the arrow one 1/3 of an editor line height | ||
if (this.options.showArrow) { | ||
arrowHeight = Math.round(lineHeight / 3); | ||
this.arrow.style.top = -arrowHeight + 'px'; | ||
this.arrow.style.borderWidth = arrowHeight + 'px'; | ||
this.arrow.style.left = this.editor.getOffsetForColumn(position.lineNumber, position.column) + 'px'; | ||
|
||
arrow = document.createElement('div'); | ||
arrow.className = 'zone-widget-arrow below'; | ||
arrow.style.top = -arrowHeight + 'px'; | ||
arrow.style.borderWidth = arrowHeight + 'px'; | ||
arrow.style.left = this.editor.getOffsetForColumn(position.lineNumber, position.column) + 'px'; | ||
arrow.style.borderBottomColor = this.options.frameColor; | ||
|
||
viewZoneDomNode.appendChild(arrow); | ||
viewZoneDomNode.appendChild(this.arrow); | ||
} | ||
|
||
// Render the frame as 1/9 of an editor line height | ||
|
@@ -281,8 +279,6 @@ export abstract class ZoneWidget extends Widget implements IHorizontalSashLayout | |
|
||
if (this.options.showFrame) { | ||
const width = this.options.frameWidth ? this.options.frameWidth : frameThickness; | ||
this.container.style.borderTopColor = this.options.frameColor; | ||
this.container.style.borderBottomColor = this.options.frameColor; | ||
this.container.style.borderTopWidth = width + 'px'; | ||
this.container.style.borderBottomWidth = width + 'px'; | ||
} | ||
|
@@ -302,6 +298,20 @@ export abstract class ZoneWidget extends Widget implements IHorizontalSashLayout | |
this.editor.revealLine(revealLineNumber); | ||
} | ||
|
||
protected setCssClass(className: string, classToReplace?: string): void { | ||
if (classToReplace) { | ||
this.container.classList.remove(classToReplace); | ||
if (this.arrow) { | ||
this.arrow.classList.remove(classToReplace); | ||
} | ||
} | ||
|
||
this.container.classList.add(className); | ||
if (this.arrow) { | ||
this.arrow.classList.add(className); | ||
} | ||
} | ||
|
||
protected abstract _fillContainer(container: HTMLElement): void; | ||
|
||
protected _onWidth(widthInPixel: number): void { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import 'vs/css!../browser/media/exceptionWidget'; | ||
import * as nls from 'vs/nls'; | ||
import * as dom from 'vs/base/browser/dom'; | ||
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget'; | ||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; | ||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; | ||
import { IDebugService } from 'vs/workbench/parts/debug/common/debug'; | ||
const $ = dom.$; | ||
|
||
export class ExceptionWidget extends ZoneWidget { | ||
|
||
constructor(editor: ICodeEditor, private lineNumber: number, | ||
@IContextViewService private contextViewService: IContextViewService, | ||
@IDebugService private debugService: IDebugService | ||
) { | ||
super(editor, { showFrame: true, showArrow: true, frameWidth: 1 }); | ||
|
||
this.create(); | ||
} | ||
|
||
protected _fillContainer(container: HTMLElement): void { | ||
this.setCssClass('exception-widget'); | ||
|
||
let title = $('.title'); | ||
title.textContent = nls.localize('exceptionThrown', 'Exception occured.'); | ||
dom.append(container, title); | ||
|
||
const thread = this.debugService.getViewModel().focusedThread; | ||
if (thread && thread.stoppedDetails) { | ||
let msg = $('.message'); | ||
msg.textContent = thread.stoppedDetails.text; | ||
dom.append(container, msg); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
.monaco-editor .zone-widget .zone-widget-container.breakpoint-widget { | ||
height: 30px !important; | ||
display: flex; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to put it in one rule together |
||
border-color: #007ACC; | ||
} | ||
|
||
.monaco-editor .zone-widget .zone-widget-container.breakpoint-widget .breakpoint-select-container { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good