From 6779fd96bfbfa297e643bf0c76329a4a63bf341d Mon Sep 17 00:00:00 2001 From: Andrea Mah <31675041+andreamah@users.noreply.github.com> Date: Fri, 15 Jul 2022 09:52:17 -0700 Subject: Add "Go to Last Failed Cell" Button (#154443) * Add go to last failed cell function --- src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts | 1 + .../contrib/notebook/common/notebookExecutionStateService.ts | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'src/vs/workbench/contrib/notebook/common') diff --git a/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts b/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts index e629ed034d2..fd9692eba0f 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts @@ -24,6 +24,7 @@ export const NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON = new RawContextKey('notebookBreakpointMargin', false); export const NOTEBOOK_CELL_TOOLBAR_LOCATION = new RawContextKey<'left' | 'right' | 'hidden'>('notebookCellToolbarLocation', 'left'); export const NOTEBOOK_CURSOR_NAVIGATION_MODE = new RawContextKey('notebookCursorNavigationMode', false); +export const NOTEBOOK_LAST_CELL_FAILED = new RawContextKey('notebookLastCellFailed', false); // Cell keys export const NOTEBOOK_VIEW_TYPE = new RawContextKey('notebookType', undefined); diff --git a/src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.ts b/src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.ts index f6317245bb1..d1fbe75907f 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.ts @@ -39,6 +39,10 @@ export interface ICellExecutionStateChangedEvent { affectsCell(cell: URI): boolean; affectsNotebook(notebook: URI): boolean; } +export interface INotebookFailStateChangedEvent { + failed: boolean; + notebook: URI; +} export const INotebookExecutionStateService = createDecorator('INotebookExecutionStateService'); @@ -46,11 +50,13 @@ export interface INotebookExecutionStateService { _serviceBrand: undefined; onDidChangeCellExecution: Event; + onDidChangeLastRunFailState: Event; forceCancelNotebookExecutions(notebookUri: URI): void; getCellExecutionStatesForNotebook(notebook: URI): INotebookCellExecution[]; getCellExecution(cellUri: URI): INotebookCellExecution | undefined; createCellExecution(notebook: URI, cellHandle: number): INotebookCellExecution; + getLastFailedCellForNotebook(notebook: URI): number | undefined; } export interface INotebookCellExecution { -- cgit v1.2.3 From 425a6dec811366e465958b57d0121413a4b538dc Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 15 Jul 2022 12:17:24 -0700 Subject: Fix notebook perf markers (#155266) Fixes #135834 --- .../contrib/notebook/common/notebookEditorInput.ts | 6 ++-- .../contrib/notebook/common/notebookPerformance.ts | 36 ++++++---------------- 2 files changed, 13 insertions(+), 29 deletions(-) (limited to 'src/vs/workbench/contrib/notebook/common') diff --git a/src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts b/src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts index b8cbd4985d0..54e0ac40f5e 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts @@ -16,7 +16,6 @@ import { IDisposable, IReference } from 'vs/base/common/lifecycle'; import { CellEditType, IResolvedNotebookEditorModel } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { ILabelService } from 'vs/platform/label/common/label'; import { Schemas } from 'vs/base/common/network'; -import { mark } from 'vs/workbench/contrib/notebook/common/notebookPerformance'; import { FileSystemProviderCapabilities, IFileService } from 'vs/platform/files/common/files'; import { AbstractResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput'; import { IResourceEditorInput } from 'vs/platform/editor/common/editor'; @@ -24,6 +23,7 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import { VSBuffer } from 'vs/base/common/buffer'; import { IWorkingCopyIdentifier } from 'vs/workbench/services/workingCopy/common/workingCopy'; import { NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider'; +import { NotebookPerfMarks } from 'vs/workbench/contrib/notebook/common/notebookPerformance'; export interface NotebookEditorInputOptions { startDirty?: boolean; @@ -231,12 +231,12 @@ export class NotebookEditorInput extends AbstractResourceEditorInput { } } - override async resolve(): Promise { + override async resolve(perf?: NotebookPerfMarks): Promise { if (!await this._notebookService.canResolve(this.viewType)) { return null; } - mark(this.resource, 'extensionActivated'); + perf?.mark('extensionActivated'); // we are now loading the notebook and don't need to listen to // "other" loading anymore diff --git a/src/vs/workbench/contrib/notebook/common/notebookPerformance.ts b/src/vs/workbench/contrib/notebook/common/notebookPerformance.ts index bd59c7bfbf1..c47b6eeeb2c 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookPerformance.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookPerformance.ts @@ -3,39 +3,23 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { URI } from 'vs/base/common/uri'; - export type PerfName = 'startTime' | 'extensionActivated' | 'inputLoaded' | 'webviewCommLoaded' | 'customMarkdownLoaded' | 'editorLoaded'; type PerformanceMark = { [key in PerfName]?: number }; -const perfMarks = new Map(); +export class NotebookPerfMarks { + private _marks: PerformanceMark = {}; + + get value(): PerformanceMark { + return { ...this._marks }; + } -export function mark(resource: URI, name: PerfName): void { - const key = resource.toString(); - if (!perfMarks.has(key)) { - const perfMark: PerformanceMark = {}; - perfMark[name] = Date.now(); - perfMarks.set(key, perfMark); - } else { - if (perfMarks.get(key)![name]) { + mark(name: PerfName): void { + if (this._marks[name]) { console.error(`Skipping overwrite of notebook perf value: ${name}`); return; } - perfMarks.get(key)![name] = Date.now(); - } -} -export function clearMarks(resource: URI): void { - const key = resource.toString(); - - perfMarks.delete(key); -} - -export function getAndClearMarks(resource: URI): PerformanceMark | null { - const key = resource.toString(); - - const perfMark = perfMarks.get(key) || null; - perfMarks.delete(key); - return perfMark; + this._marks[name] = Date.now(); + } } -- cgit v1.2.3