diff --git a/Source/extension.ts b/Source/extension.ts index 0a669e0..0845c38 100644 --- a/Source/extension.ts +++ b/Source/extension.ts @@ -42,7 +42,7 @@ function startTour(params: URLSearchParams) { } const tour = store.tours.find((tour) => - tour.id.endsWith(tourPath as string) + tour.id.endsWith(tourPath as string), ); if (tour) { startCodeTour(tour, stepNumber); diff --git a/Source/git.ts b/Source/git.ts index d3ed9ec..4dcb3f3 100644 --- a/Source/git.ts +++ b/Source/git.ts @@ -3,10 +3,10 @@ import * as vscode from "vscode"; -export const enum RefType { - Head, - RemoteHead, - Tag, +export enum RefType { + Head = 0, + RemoteHead = 1, + Tag = 2, } export interface Ref { diff --git a/Source/liveShare/index.ts b/Source/liveShare/index.ts index 2a5667b..afcdf30 100644 --- a/Source/liveShare/index.ts +++ b/Source/liveShare/index.ts @@ -20,7 +20,7 @@ export async function registerLiveShareModule() { } async function initializeService(vslsApi: vsls.LiveShare) { - let { initializeService } = + const { initializeService } = vslsApi.session.role === vsls.Role.Host ? require("./hostService") : require("./guestService"); diff --git a/Source/liveShare/service.ts b/Source/liveShare/service.ts index 8992d7a..29825c5 100644 --- a/Source/liveShare/service.ts +++ b/Source/liveShare/service.ts @@ -20,7 +20,7 @@ const TOUR_STARTED_NOTIFICATION = "tourStarted"; export default function ( api: LiveShare, - service: SharedService | SharedServiceProxy + service: SharedService | SharedServiceProxy, ) { const peer = api.session.peerNumber; diff --git a/Source/notebook/index.ts b/Source/notebook/index.ts index 7a869fb..a12605f 100644 --- a/Source/notebook/index.ts +++ b/Source/notebook/index.ts @@ -11,16 +11,16 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer { async deserializeNotebook( content: Uint8Array, - token: any + token: any, ): Promise { this.originalContent = content; - let contents = new TextDecoder().decode(content); + const contents = new TextDecoder().decode(content); - let tour = JSON.parse(contents); + const tour = JSON.parse(contents); const workspaceRoot = getWorkspaceUri(tour); - let steps: any[] = []; + const steps: any[] = []; - for (let item of tour.steps) { + for (const item of tour.steps) { const uri = await getStepFileUri(item, workspaceRoot, tour.ref); const document = await vscode.workspace.openTextDocument(uri); @@ -29,8 +29,8 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer { const contents = document.getText( new vscode.Range( new vscode.Position(startLine, 0), - new vscode.Position(endLine, 10000) - ) + new vscode.Position(endLine, 10000), + ), ); steps.push({ contents, @@ -40,7 +40,7 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer { }); } - let cells: vscode.NotebookCellData[] = []; + const cells: vscode.NotebookCellData[] = []; // Title cell cells.push( @@ -51,15 +51,15 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer { }) - ${steps.length} steps\n\n${ tour.description === undefined ? "" : tour.description }`, - "markdown" - ) + "markdown", + ), ); steps.forEach((step, index) => { const cell = new vscode.NotebookCellData( 2, step.contents, - step.language + step.language, ); cell.outputs = [ new vscode.NotebookCellOutput([ @@ -67,9 +67,9 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer { new TextEncoder().encode( `_Step #${index + 1} of ${steps.length}:_ ${ step.description - } ([View File](${step.uri}))` + } ([View File](${step.uri}))`, ), - "text/markdown" + "text/markdown", ), ]), ]; @@ -80,7 +80,7 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer { async serializeNotebook( data: vscode.NotebookData, - token: any + token: any, ): Promise { return this.originalContent; } @@ -89,6 +89,6 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer { export function registerNotebookProvider() { vscode.notebook.registerNotebookSerializer( EXTENSION_NAME, - new CodeTourNotebookProvider() + new CodeTourNotebookProvider(), ); } diff --git a/Source/notebook/vscode.proposed.d.ts b/Source/notebook/vscode.proposed.d.ts index f144407..20ac246 100644 --- a/Source/notebook/vscode.proposed.d.ts +++ b/Source/notebook/vscode.proposed.d.ts @@ -54,7 +54,7 @@ declare module "vscode" { */ export function logout( providerId: string, - sessionId: string + sessionId: string, ): Thenable; } @@ -148,10 +148,10 @@ declare module "vscode" { export class RemoteAuthorityResolverError extends Error { static NotAvailable( message?: string, - handled?: boolean + handled?: boolean, ): RemoteAuthorityResolverError; static TemporarilyNotAvailable( - message?: string + message?: string, ): RemoteAuthorityResolverError; constructor(message?: string); @@ -160,7 +160,7 @@ declare module "vscode" { export interface RemoteAuthorityResolver { resolve( authority: string, - context: RemoteAuthorityResolverContext + context: RemoteAuthorityResolverContext, ): ResolverResult | Thenable; /** * Can be optionally implemented if the extension can forward ports better than the core. @@ -172,7 +172,7 @@ declare module "vscode" { */ tunnelFactory?: ( tunnelOptions: TunnelOptions, - tunnelCreationOptions: TunnelCreationOptions + tunnelCreationOptions: TunnelCreationOptions, ) => Thenable | undefined; /**p @@ -181,7 +181,7 @@ declare module "vscode" { showCandidatePort?: ( host: string, port: number, - detail: string + detail: string, ) => Thenable; /** @@ -206,7 +206,7 @@ declare module "vscode" { * @param tunnelOptions The `localPort` is a suggestion only. If that port is not available another will be chosen. */ export function openTunnel( - tunnelOptions: TunnelOptions + tunnelOptions: TunnelOptions, ): Thenable; /** @@ -242,10 +242,10 @@ declare module "vscode" { export namespace workspace { export function registerRemoteAuthorityResolver( authorityPrefix: string, - resolver: RemoteAuthorityResolver + resolver: RemoteAuthorityResolver, ): Disposable; export function registerResourceLabelFormatter( - formatter: ResourceLabelFormatter + formatter: ResourceLabelFormatter, ): Disposable; } @@ -267,7 +267,7 @@ declare module "vscode" { editor: TextEditor, line: number, height: number, - options?: WebviewOptions + options?: WebviewOptions, ): WebviewEditorInset; } @@ -278,7 +278,7 @@ declare module "vscode" { export interface FileSystemProvider { open?( resource: Uri, - options: { create: boolean } + options: { create: boolean }, ): number | Thenable; close?(fd: number): void | Thenable; read?( @@ -286,14 +286,14 @@ declare module "vscode" { pos: number, data: Uint8Array, offset: number, - length: number + length: number, ): number | Thenable; write?( fd: number, pos: number, data: Uint8Array, offset: number, - length: number + length: number, ): number | Thenable; } @@ -536,7 +536,7 @@ declare module "vscode" { query: TextSearchQuery, options: TextSearchOptions, progress: Progress, - token: CancellationToken + token: CancellationToken, ): ProviderResult; } @@ -589,7 +589,7 @@ declare module "vscode" { provideFileSearchResults( query: FileSearchQuery, options: FileSearchOptions, - token: CancellationToken + token: CancellationToken, ): ProviderResult; } @@ -605,7 +605,7 @@ declare module "vscode" { */ export function registerFileSearchProvider( scheme: string, - provider: FileSearchProvider + provider: FileSearchProvider, ): Disposable; /** @@ -619,7 +619,7 @@ declare module "vscode" { */ export function registerTextSearchProvider( scheme: string, - provider: TextSearchProvider + provider: TextSearchProvider, ): Disposable; } @@ -706,7 +706,7 @@ declare module "vscode" { export function findTextInFiles( query: TextSearchQuery, callback: (result: TextSearchResult) => void, - token?: CancellationToken + token?: CancellationToken, ): Thenable; /** @@ -721,7 +721,7 @@ declare module "vscode" { query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, - token?: CancellationToken + token?: CancellationToken, ): Thenable; } @@ -757,7 +757,7 @@ declare module "vscode" { export function registerDiffInformationCommand( command: string, callback: (diff: LineChange[], ...args: any[]) => any, - thisArg?: any + thisArg?: any, ): Disposable; } @@ -770,17 +770,13 @@ declare module "vscode" { * A DebugProtocolVariableContainer is an opaque stand-in type for the intersection of the Scope and Variable types defined in the Debug Adapter Protocol. * See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope and https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable. */ - export interface DebugProtocolVariableContainer { - // Properties: the intersection of DAP's Scope and Variable types. - } + export type DebugProtocolVariableContainer = {}; /** * A DebugProtocolVariable is an opaque stand-in type for the Variable type defined in the Debug Adapter Protocol. * See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable. */ - export interface DebugProtocolVariable { - // Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_Variable). - } + export type DebugProtocolVariable = {}; //#endregion @@ -828,7 +824,7 @@ declare module "vscode" { */ showValidationMessage( message: string, - type: SourceControlInputBoxValidationType + type: SourceControlInputBoxValidationType, ): void; /** @@ -837,7 +833,7 @@ declare module "vscode" { */ validateInput?( value: string, - cursorPosition: number + cursorPosition: number, ): ProviderResult; } @@ -959,7 +955,7 @@ declare module "vscode" { select?: boolean; focus?: boolean; expand?: boolean | number; - } + }, ): Thenable; } //#endregion @@ -1020,7 +1016,7 @@ declare module "vscode" { * @return A new status bar item. */ export function createStatusBarItem( - options?: StatusBarItemOptions + options?: StatusBarItemOptions, ): StatusBarItem; } @@ -1047,7 +1043,7 @@ declare module "vscode" { moveCustomTextEditor?( newDocument: TextDocument, existingWebviewPanel: WebviewPanel, - token: CancellationToken + token: CancellationToken, ): Thenable; } @@ -1351,7 +1347,7 @@ declare module "vscode" { */ revealRange( range: NotebookRange, - revealType?: NotebookEditorRevealType + revealType?: NotebookEditorRevealType, ): void; /** @@ -1443,7 +1439,7 @@ declare module "vscode" { language: string, outputs?: NotebookCellOutput[], metadata?: NotebookCellMetadata, - latestExecutionSummary?: NotebookCellExecutionSummary + latestExecutionSummary?: NotebookCellExecutionSummary, ); } @@ -1452,7 +1448,7 @@ declare module "vscode" { metadata: NotebookDocumentMetadata; constructor( cells: NotebookCellData[], - metadata?: NotebookDocumentMetadata + metadata?: NotebookDocumentMetadata, ); } @@ -1465,7 +1461,7 @@ declare module "vscode" { export namespace notebook { export function openNotebookDocument( - uri: Uri + uri: Uri, ): Thenable; export const onDidOpenNotebookDocument: Event; @@ -1499,11 +1495,11 @@ declare module "vscode" { export function showNotebookDocument( uri: Uri, - options?: NotebookDocumentShowOptions + options?: NotebookDocumentShowOptions, ): Thenable; export function showNotebookDocument( document: NotebookDocument, - options?: NotebookDocumentShowOptions + options?: NotebookDocumentShowOptions, ): Thenable; } @@ -1529,7 +1525,7 @@ declare module "vscode" { constructor( mime: string, value: unknown, - metadata?: Record + metadata?: Record, ); } @@ -1540,12 +1536,12 @@ declare module "vscode" { metadata?: Record; constructor( outputs: NotebookCellOutputItem[], - metadata?: Record + metadata?: Record, ); constructor( outputs: NotebookCellOutputItem[], id: string, - metadata?: Record + metadata?: Record, ); } @@ -1573,19 +1569,19 @@ declare module "vscode" { // todo@API add NotebookEdit-type which handles all these cases? replaceNotebookMetadata( uri: Uri, - value: NotebookDocumentMetadata + value: NotebookDocumentMetadata, ): void; replaceNotebookCells( uri: Uri, range: NotebookRange, cells: NotebookCellData[], - metadata?: WorkspaceEditEntryMetadata + metadata?: WorkspaceEditEntryMetadata, ): void; replaceNotebookCellMetadata( uri: Uri, index: number, cellMetadata: NotebookCellMetadata, - metadata?: WorkspaceEditEntryMetadata + metadata?: WorkspaceEditEntryMetadata, ): void; } @@ -1594,11 +1590,11 @@ declare module "vscode" { replaceCells( start: number, end: number, - cells: NotebookCellData[] + cells: NotebookCellData[], ): void; replaceCellMetadata( index: number, - metadata: NotebookCellMetadata + metadata: NotebookCellMetadata, ): void; } @@ -1615,7 +1611,7 @@ declare module "vscode" { */ // @jrieken REMOVE maybe edit( - callback: (editBuilder: NotebookEditorEdit) => void + callback: (editBuilder: NotebookEditorEdit) => void, ): Thenable; } @@ -1641,7 +1637,7 @@ declare module "vscode" { */ deserializeNotebook( content: Uint8Array, - token: CancellationToken + token: CancellationToken, ): NotebookData | Thenable; /** @@ -1653,7 +1649,7 @@ declare module "vscode" { */ serializeNotebook( data: NotebookData, - token: CancellationToken + token: CancellationToken, ): Uint8Array | Thenable; } @@ -1670,7 +1666,7 @@ declare module "vscode" { export function registerNotebookSerializer( notebookType: string, serializer: NotebookSerializer, - options?: NotebookDocumentContentOptions + options?: NotebookDocumentContentOptions, ): Disposable; } @@ -1699,7 +1695,7 @@ declare module "vscode" { this: NotebookController, cells: NotebookCell[], notebook: NotebookDocument, - controller: NotebookController + controller: NotebookController, ): void | Thenable; } @@ -1709,7 +1705,7 @@ declare module "vscode" { */ ( this: NotebookController, - notebook: NotebookDocument + notebook: NotebookDocument, ): void | Thenable; } @@ -1802,7 +1798,7 @@ declare module "vscode" { * @returns A notebook cell execution. */ createNotebookCellExecutionTask( - cell: NotebookCell + cell: NotebookCell, ): NotebookCellExecutionTask; // todo@API find a better name than "preloads" @@ -1842,7 +1838,7 @@ declare module "vscode" { */ updateNotebookAffinity( notebook: NotebookDocument, - affinity: NotebookControllerAffinity + affinity: NotebookControllerAffinity, ): void; } @@ -1866,7 +1862,7 @@ declare module "vscode" { viewType: string, label: string, handler?: NotebookExecuteHandler, - preloads?: NotebookKernelPreload[] + preloads?: NotebookKernelPreload[], ): NotebookController; } @@ -1913,27 +1909,27 @@ declare module "vscode" { openNotebook( uri: Uri, openContext: NotebookDocumentOpenContext, - token: CancellationToken + token: CancellationToken, ): NotebookData | Thenable; // todo@API use NotebookData instead saveNotebook( document: NotebookDocument, - token: CancellationToken + token: CancellationToken, ): Thenable; // todo@API use NotebookData instead saveNotebookAs( targetResource: Uri, document: NotebookDocument, - token: CancellationToken + token: CancellationToken, ): Thenable; // todo@API use NotebookData instead backupNotebook( document: NotebookDocument, context: NotebookDocumentBackupContext, - token: CancellationToken + token: CancellationToken, ): Thenable; } @@ -1957,7 +1953,7 @@ declare module "vscode" { export function registerNotebookContentProvider( notebookType: string, provider: NotebookContentProvider, - options?: NotebookDocumentContentOptions + options?: NotebookDocumentContentOptions, ): Disposable; } @@ -2016,19 +2012,19 @@ declare module "vscode" { clearOutput(cellIndex?: number): Thenable; appendOutput( out: NotebookCellOutput | NotebookCellOutput[], - cellIndex?: number + cellIndex?: number, ): Thenable; replaceOutput( out: NotebookCellOutput | NotebookCellOutput[], - cellIndex?: number + cellIndex?: number, ): Thenable; appendOutputItems( items: NotebookCellOutputItem | NotebookCellOutputItem[], - outputId: string + outputId: string, ): Thenable; replaceOutputItems( items: NotebookCellOutputItem | NotebookCellOutputItem[], - outputId: string + outputId: string, ): Thenable; } @@ -2043,7 +2039,7 @@ declare module "vscode" { export function createNotebookCellExecutionTask( uri: Uri, index: number, - kernelId: string + kernelId: string, ): NotebookCellExecutionTask | undefined; export const onDidChangeCellExecutionState: Event; @@ -2056,7 +2052,7 @@ declare module "vscode" { export interface NotebookEditor { setDecorations( decorationType: NotebookEditorDecorationType, - range: NotebookRange + range: NotebookRange, ): void; } @@ -2073,7 +2069,7 @@ declare module "vscode" { export namespace notebook { export function createNotebookEditorDecorationType( - options: NotebookDecorationRenderOptions + options: NotebookDecorationRenderOptions, ): NotebookEditorDecorationType; } @@ -2110,7 +2106,7 @@ declare module "vscode" { command?: string | Command, tooltip?: string, priority?: number, - accessibilityInformation?: AccessibilityInformation + accessibilityInformation?: AccessibilityInformation, ); } @@ -2125,14 +2121,14 @@ declare module "vscode" { */ provideCellStatusBarItems( cell: NotebookCell, - token: CancellationToken + token: CancellationToken, ): ProviderResult; } export namespace notebook { export function registerNotebookCellStatusBarItemProvider( selector: NotebookSelector, - provider: NotebookCellStatusBarItemProvider + provider: NotebookCellStatusBarItemProvider, ): Disposable; } @@ -2151,7 +2147,7 @@ declare module "vscode" { // todo@API really needed? we didn't find a user here export function createConcatTextDocument( notebook: NotebookDocument, - selector?: DocumentSelector + selector?: DocumentSelector, ): NotebookConcatTextDocument; } @@ -2350,7 +2346,7 @@ declare module "vscode" { provideTimeline( uri: Uri, options: TimelineOptions, - token: CancellationToken + token: CancellationToken, ): ProviderResult; } @@ -2368,7 +2364,7 @@ declare module "vscode" { */ export function registerTimelineProvider( scheme: string | string[], - provider: TimelineProvider + provider: TimelineProvider, ): Disposable; } @@ -2391,7 +2387,7 @@ declare module "vscode" { export namespace languages { export function getTokenInformationAtPosition( document: TextDocument, - position: Position + position: Position, ): Thenable; } @@ -2419,7 +2415,7 @@ declare module "vscode" { */ export function registerInlayHintsProvider( selector: DocumentSelector, - provider: InlayHintsProvider + provider: InlayHintsProvider, ): Disposable; } @@ -2479,7 +2475,7 @@ declare module "vscode" { provideInlayHints( model: TextDocument, range: Range, - token: CancellationToken + token: CancellationToken, ): ProviderResult; } //#endregion @@ -2521,7 +2517,7 @@ declare module "vscode" { * run tests in workspaces and documents. */ export function registerTestController( - testController: TestController + testController: TestController, ): Disposable; /** @@ -2531,7 +2527,7 @@ declare module "vscode" { */ export function runTests( run: TestRunRequest, - token?: CancellationToken + token?: CancellationToken, ): Thenable; /** @@ -2539,7 +2535,7 @@ declare module "vscode" { * @stability experimental */ export function createWorkspaceTestObserver( - workspaceFolder: WorkspaceFolder + workspaceFolder: WorkspaceFolder, ): TestObserver; /** @@ -2547,7 +2543,7 @@ declare module "vscode" { * @stability experimental */ export function createDocumentTestObserver( - document: TextDocument + document: TextDocument, ): TestObserver; /** @@ -2569,7 +2565,7 @@ declare module "vscode" { export function createTestRun( request: TestRunRequest, name?: string, - persist?: boolean + persist?: boolean, ): TestRun; /** @@ -2579,7 +2575,7 @@ declare module "vscode" { */ export function createTestItem( options: TestItemOptions, - data: T + data: T, ): TestItem; /** @@ -2587,7 +2583,7 @@ declare module "vscode" { * @param options Initial/required options for the item */ export function createTestItem( - options: TestItemOptions + options: TestItemOptions, ): TestItem; /** @@ -2675,7 +2671,7 @@ declare module "vscode" { */ createWorkspaceTestRoot( workspace: WorkspaceFolder, - token: CancellationToken + token: CancellationToken, ): ProviderResult>; /** @@ -2697,7 +2693,7 @@ declare module "vscode" { */ createDocumentTestRoot?( document: TextDocument, - token: CancellationToken + token: CancellationToken, ): ProviderResult>; /** @@ -2711,7 +2707,7 @@ declare module "vscode" { */ runTests( options: TestRunRequest, - token: CancellationToken + token: CancellationToken, ): Thenable | void; } @@ -2762,7 +2758,7 @@ declare module "vscode" { setState( test: TestItem, state: TestResultState, - duration?: number + duration?: number, ): void; /** @@ -3028,7 +3024,7 @@ declare module "vscode" { static diff( message: string | MarkdownString, expected: string, - actual: string + actual: string, ): TestMessage; /** @@ -3200,7 +3196,7 @@ declare module "vscode" { */ canOpenExternalUri( uri: Uri, - token: CancellationToken + token: CancellationToken, ): ExternalUriOpenerPriority | Thenable; /** @@ -3223,7 +3219,7 @@ declare module "vscode" { openExternalUri( resolvedUri: Uri, ctx: OpenExternalUriContext, - token: CancellationToken + token: CancellationToken, ): Thenable | void; } @@ -3275,7 +3271,7 @@ declare module "vscode" { export function registerExternalUriOpener( id: string, opener: ExternalUriOpener, - metadata: ExternalUriOpenerMetadata + metadata: ExternalUriOpenerMetadata, ): Disposable; } @@ -3297,7 +3293,7 @@ declare module "vscode" { namespace env { export function openExternal( target: Uri, - options?: OpenExternalOptions + options?: OpenExternalOptions, ): Thenable; } @@ -3342,7 +3338,7 @@ declare module "vscode" { * `onDidGrantWorkspaceTrust` event to listen for trust changes. */ export function requestWorkspaceTrust( - options?: WorkspaceTrustRequestOptions + options?: WorkspaceTrustRequestOptions, ): Thenable; } @@ -3393,7 +3389,7 @@ declare module "vscode" { port: number, pid: number | undefined, commandLine: string | undefined, - token: CancellationToken + token: CancellationToken, ): ProviderResult; } @@ -3416,7 +3412,7 @@ declare module "vscode" { portRange?: [number, number]; commandMatcher?: RegExp; }, - provider: PortAttributesProvider + provider: PortAttributesProvider, ): Disposable; } //#endregion diff --git a/Source/player/codeStatus.ts b/Source/player/codeStatus.ts index cec3e78..d21b060 100644 --- a/Source/player/codeStatus.ts +++ b/Source/player/codeStatus.ts @@ -3,7 +3,7 @@ import { onDidEndTour, onDidStartTour } from "../store/actions"; export async function registerCodeStatusModule() { const extension = vscode.extensions.getExtension( - "lostintangent.codestatus" + "lostintangent.codestatus", ); if (!extension) { return; diff --git a/Source/player/commands.ts b/Source/player/commands.ts index 64d9e4e..40c8229 100644 --- a/Source/player/commands.ts +++ b/Source/player/commands.ts @@ -30,7 +30,7 @@ export function registerPlayerCommands() { if (tour) { startCodeTour(tour, stepNumber); } - } + }, ); // Purpose: Command link @@ -46,10 +46,10 @@ export function registerPlayerCommands() { store.activeTour?.workspaceRoot, undefined, undefined, - store.activeTour?.tours + store.activeTour?.tours, ); } - } + }, ); vscode.commands.registerCommand( @@ -60,12 +60,12 @@ export function registerPlayerCommands() { if (title) { vscode.commands.executeCommand( `${EXTENSION_NAME}.startTourByTitle`, - title + title, ); } else { vscode.commands.executeCommand(`${EXTENSION_NAME}.endTour`); } - } + }, ); // Purpose: Command link @@ -78,9 +78,9 @@ export function registerPlayerCommands() { store.activeTour?.workspaceRoot, undefined, undefined, - store.activeTour?.tours + store.activeTour?.tours, ); - } + }, ); // Purpose: Command link and the ">>" syntax @@ -97,13 +97,13 @@ export function registerPlayerCommands() { when( () => store.activeTour === null, - () => terminal?.dispose() + () => terminal?.dispose(), ); } terminal.show(); terminal.sendText(text, true); - } + }, ); vscode.commands.registerCommand( @@ -118,14 +118,14 @@ export function registerPlayerCommands() { step.selection!.start.line - 1, step.selection!.start.character - 1, step.selection!.end.line - 1, - step.selection!.end.character - 1 + step.selection!.end.character - 1, ); e.replace(selection, codeSnippet); }); } else { const position = new vscode.Position(step.line! - 1, 0); await vscode.window.activeTextEditor?.edit((e) => - e.insert(position, codeSnippet) + e.insert(position, codeSnippet), ); } @@ -138,9 +138,9 @@ export function registerPlayerCommands() { } await vscode.commands.executeCommand( - "editor.action.formatDocument" + "editor.action.formatDocument", ); - } + }, ); vscode.commands.registerCommand( @@ -149,7 +149,7 @@ export function registerPlayerCommands() { tour?: CodeTour | CodeTourNode, stepNumber?: number, workspaceRoot?: vscode.Uri, - tours?: CodeTour[] + tours?: CodeTour[], ) => { if (tour) { const targetTour = @@ -160,12 +160,12 @@ export function registerPlayerCommands() { workspaceRoot, undefined, undefined, - tours + tours, ); } selectTour(store.tours, workspaceRoot); - } + }, ); vscode.commands.registerCommand( @@ -173,27 +173,27 @@ export function registerPlayerCommands() { async (node: CodeTourNode) => { const tourUri = vscode.Uri.parse(node.tour.id); vscode.window.showTextDocument(tourUri); - } + }, ); vscode.commands.registerCommand( `${EXTENSION_NAME}.endTour`, - endCurrentCodeTour + endCurrentCodeTour, ); vscode.commands.registerCommand( `${EXTENSION_NAME}.previousTourStep`, - moveCurrentCodeTourBackward + moveCurrentCodeTourBackward, ); vscode.commands.registerCommand( `${EXTENSION_NAME}.nextTourStep`, - moveCurrentCodeTourForward + moveCurrentCodeTourForward, ); vscode.commands.registerCommand( `${EXTENSION_NAME}.resumeTour`, - focusPlayer + focusPlayer, ); vscode.commands.registerCommand( @@ -221,10 +221,10 @@ export function registerPlayerCommands() { startCodeTour(tour); } catch { vscode.window.showErrorMessage( - "This file doesn't appear to be a valid tour. Please inspect its contents and try again." + "This file doesn't appear to be a valid tour. Please inspect its contents and try again.", ); } - } + }, ); vscode.commands.registerCommand( @@ -247,10 +247,10 @@ export function registerPlayerCommands() { startCodeTour(tour); } catch { vscode.window.showErrorMessage( - "This file doesn't appear to be a valid tour. Please inspect its contents and try again." + "This file doesn't appear to be a valid tour. Please inspect its contents and try again.", ); } - } + }, ); vscode.commands.registerCommand( @@ -270,7 +270,7 @@ export function registerPlayerCommands() { const contents = await exportTour(node.tour); const bytes = new TextEncoder().encode(contents); vscode.workspace.fs.writeFile(uri, bytes); - } + }, ); function setShowMarkers(showMarkers: boolean) { @@ -281,25 +281,25 @@ export function registerPlayerCommands() { .update( "showMarkers", showMarkers, - vscode.ConfigurationTarget.Global + vscode.ConfigurationTarget.Global, ); vscode.commands.executeCommand( "setContext", "codetour:showingMarkers", - showMarkers + showMarkers, ); } vscode.commands.registerCommand(`${EXTENSION_NAME}.hideMarkers`, () => - setShowMarkers(false) + setShowMarkers(false), ); vscode.commands.registerCommand(`${EXTENSION_NAME}.showMarkers`, () => - setShowMarkers(true) + setShowMarkers(true), ); vscode.commands.registerCommand(`${EXTENSION_NAME}.resetProgress`, () => - progress.reset() + progress.reset(), ); } diff --git a/Source/player/decorator.ts b/Source/player/decorator.ts index 1604403..20a61eb 100644 --- a/Source/player/decorator.ts +++ b/Source/player/decorator.ts @@ -18,12 +18,12 @@ const TOUR_DECORATOR = vscode.window.createTextEditorDecorationType({ }); export async function getTourSteps( - editor: vscode.TextEditor + editor: vscode.TextEditor, ): Promise { const steps: CodeTourStepTuple[] = store.tours.flatMap((tour) => tour.steps.map( - (step, stepNumber) => [tour, step, stepNumber] as CodeTourStepTuple - ) + (step, stepNumber) => [tour, step, stepNumber] as CodeTourStepTuple, + ), ); const contents = editor.document.getText(); @@ -48,7 +48,7 @@ export async function getTourSteps( return [tour, step, stepNumber, line]; } - }) + }), ); // @ts-ignore @@ -60,18 +60,18 @@ function registerHoverProvider() { return vscode.languages.registerHoverProvider("*", { provideHover: async ( document: vscode.TextDocument, - position: vscode.Position + position: vscode.Position, ) => { if (!store.activeEditorSteps) { return; } const tourSteps = store.activeEditorSteps.filter( - ([, , , line]) => line === position.line + ([, , , line]) => line === position.line, ); const hovers = tourSteps.map(([tour, _, stepNumber]) => { const args = encodeURIComponent( - JSON.stringify([tour.id, stepNumber]) + JSON.stringify([tour.id, stepNumber]), ); const command = `command:codetour._startTourById?${args}`; return `CodeTour: ${tour.title} (Step #${ @@ -87,7 +87,7 @@ function registerHoverProvider() { } export async function updateDecorations( - editor: vscode.TextEditor | undefined = vscode.window.activeTextEditor + editor: vscode.TextEditor | undefined = vscode.window.activeTextEditor, ) { if (!editor || DISABLED_SCHEMES.includes(editor.document.uri.scheme)) { return; @@ -99,7 +99,7 @@ export async function updateDecorations( } const ranges = store.activeEditorSteps!.map( - ([, , , line]) => new vscode.Range(line!, 0, line!, 1000) + ([, , , line]) => new vscode.Range(line!, 0, line!, 1000), ); editor.setDecorations(TOUR_DECORATOR, ranges); } @@ -130,7 +130,7 @@ export async function registerDecorators() { if (editor) { updateDecorations(editor); } - }) + }), ); if (activeEditor) { @@ -143,7 +143,7 @@ export async function registerDecorators() { hoverProviderDisposable = undefined; disposables = []; } - } + }, ); store.showMarkers = vscode.workspace @@ -153,6 +153,6 @@ export async function registerDecorators() { vscode.commands.executeCommand( "setContext", "codetour:showingMarkers", - store.showMarkers + store.showMarkers, ); } diff --git a/Source/player/fileSystem/documentProvider.ts b/Source/player/fileSystem/documentProvider.ts index 8346415..96a0a0c 100644 --- a/Source/player/fileSystem/documentProvider.ts +++ b/Source/player/fileSystem/documentProvider.ts @@ -11,7 +11,7 @@ class CodeTourTextDocumentContentProvider provideTextDocumentContent( uri: vscode.Uri, - token: vscode.CancellationToken + token: vscode.CancellationToken, ): vscode.ProviderResult { return ""; } @@ -20,6 +20,6 @@ class CodeTourTextDocumentContentProvider export function registerTextDocumentContentProvider() { vscode.workspace.registerTextDocumentContentProvider( FS_SCHEME_CONTENT, - new CodeTourTextDocumentContentProvider() + new CodeTourTextDocumentContentProvider(), ); } diff --git a/Source/player/fileSystem/index.ts b/Source/player/fileSystem/index.ts index 8858c7e..14c5f8f 100644 --- a/Source/player/fileSystem/index.ts +++ b/Source/player/fileSystem/index.ts @@ -49,7 +49,7 @@ export class CodeTourFileSystemProvider implements FileSystemProvider { async writeFile( uri: Uri, content: Uint8Array, - options: { create: boolean; overwrite: boolean } + options: { create: boolean; overwrite: boolean }, ): Promise { const [tour, step] = this.getCurrentTourStep(); step.contents = content.toString(); @@ -68,7 +68,7 @@ export class CodeTourFileSystemProvider implements FileSystemProvider { async rename( oldUri: Uri, newUri: Uri, - options: { overwrite: boolean } + options: { overwrite: boolean }, ): Promise { const [tour, step] = this.getCurrentTourStep(); step.file = path.basename(newUri.toString()); @@ -84,37 +84,37 @@ export class CodeTourFileSystemProvider implements FileSystemProvider { async copy?( source: Uri, destination: Uri, - options: { overwrite: boolean } + options: { overwrite: boolean }, ): Promise { throw FileSystemError.NoPermissions( - "CodeTour doesn't support copying files." + "CodeTour doesn't support copying files.", ); } createDirectory(uri: Uri): void { throw FileSystemError.NoPermissions( - "CodeTour doesn't support directories." + "CodeTour doesn't support directories.", ); } async delete(uri: Uri, options: { recursive: boolean }): Promise { throw FileSystemError.NoPermissions( - "CodeTour doesn't support deleting files." + "CodeTour doesn't support deleting files.", ); } async readDirectory(uri: Uri): Promise<[string, FileType][]> { throw FileSystemError.NoPermissions( - "CodeTour doesnt support directories." + "CodeTour doesnt support directories.", ); } watch( uri: Uri, - options: { recursive: boolean; excludes: string[] } + options: { recursive: boolean; excludes: string[] }, ): Disposable { throw FileSystemError.NoPermissions( - "CodeTour doesn't support watching files." + "CodeTour doesn't support watching files.", ); } } @@ -122,6 +122,6 @@ export class CodeTourFileSystemProvider implements FileSystemProvider { export function registerFileSystemProvider() { workspace.registerFileSystemProvider( FS_SCHEME, - new CodeTourFileSystemProvider() + new CodeTourFileSystemProvider(), ); } diff --git a/Source/player/index.ts b/Source/player/index.ts index ed3d04d..74b7eac 100644 --- a/Source/player/index.ts +++ b/Source/player/index.ts @@ -3,12 +3,10 @@ import { reaction } from "mobx"; import { - commands, Comment, CommentAuthorInformation, CommentController, CommentMode, - comments, CommentThread, CommentThreadCollapsibleState, ExtensionContext, @@ -18,6 +16,8 @@ import { TextDocument, TextEditorRevealType, Uri, + commands, + comments, window, workspace, } from "vscode"; @@ -61,7 +61,7 @@ export function generatePreviewContent(content: string) { const args = encodeURIComponent(JSON.stringify([script])); const s = `> [${script}](command:codetour.sendTextToTerminal?${args} "Run \\"${script.replace( /"/g, - "'" + "'", )}\\" in a terminal")`; return s; }) @@ -71,7 +71,7 @@ export function generatePreviewContent(content: string) { }) .replace(FILE_REFERENCE_PATTERN, (_, isImage, prefix, filePath) => { const workspaceUri = workspace.getWorkspaceFolder( - Uri.parse(store.activeTour!.tour.id) + Uri.parse(store.activeTour!.tour.id), )!.uri; const fileUri = Uri.joinPath(workspaceUri, filePath); @@ -92,7 +92,7 @@ export function generatePreviewContent(content: string) { const tours = store.activeTour?.tours || store.tours; const tour = tours.find( - (tour) => getTourTitle(tour) === tourTitle + (tour) => getTourTitle(tour) === tourTitle, ); if (tour) { const args: [string, number?] = [tour.title]; @@ -101,14 +101,14 @@ export function generatePreviewContent(content: string) { args.push(Number(stepNumber)); } const argsContent = encodeURIComponent( - JSON.stringify(args) + JSON.stringify(args), ); const title = linkTitle || tour.title; return `[${title}](command:codetour.startTourByTitle?${argsContent} "Start \\"${tour.title}\\" tour")`; } return _; - } + }, ) .replace(CODE_FENCE_PATTERN, (_, codeBlock) => { const params = encodeURIComponent(JSON.stringify([codeBlock])); @@ -119,7 +119,7 @@ export function generatePreviewContent(content: string) { export class CodeTourComment implements Comment { public id: string = (++id).toString(); - public contextValue: string = ""; + public contextValue = ""; public author: CommentAuthorInformation = { name: CONTROLLER_LABEL, iconPath: Uri.parse(SMALL_ICON_URL), @@ -128,9 +128,9 @@ export class CodeTourComment implements Comment { constructor( content: string, - public label: string = "", + public label = "", public parent: CommentThread, - public mode: CommentMode + public mode: CommentMode, ) { const body = mode === CommentMode.Preview @@ -156,7 +156,7 @@ export async function startPlayer() { controller = comments.createCommentController( CONTROLLER_ID, - CONTROLLER_LABEL + CONTROLLER_LABEL, ); // TODO: Correctly limit the commenting ranges @@ -205,7 +205,7 @@ const VIEW_COMMANDS = new Map([ function getPreviousTour(): CodeTour | undefined { const previousTour = store.tours.find( - (tour) => tour.nextTour === store.activeTour?.tour.title + (tour) => tour.nextTour === store.activeTour?.tour.title, ); if (previousTour) { @@ -216,7 +216,7 @@ function getPreviousTour(): CodeTour | undefined { if (match) { const previousTourNumber = Number(match[1]) - 1; return store.tours.find((tour) => - tour.title.match(new RegExp(`^#?${previousTourNumber}\\s+[-:]`)) + tour.title.match(new RegExp(`^#?${previousTourNumber}\\s+[-:]`)), ); } } @@ -224,14 +224,14 @@ function getPreviousTour(): CodeTour | undefined { function getNextTour(): CodeTour | undefined { if (store.activeTour?.tour.nextTour) { return store.tours.find( - (tour) => tour.title === store.activeTour?.tour.nextTour + (tour) => tour.title === store.activeTour?.tour.nextTour, ); } else { const tourNumber = getActiveTourNumber(); if (tourNumber) { const nextTourNumber = tourNumber + 1; return store.tours.find((tour) => - tour.title.match(new RegExp(`^#?${nextTourNumber}\\s+[-:]`)) + tour.title.match(new RegExp(`^#?${nextTourNumber}\\s+[-:]`)), ); } } @@ -256,8 +256,8 @@ async function renderCurrentStep() { let line = step.line ? step.line - 1 : step.selection - ? step.selection.end.line - 1 - : undefined; + ? step.selection.end.line - 1 + : undefined; if (step.file && line === undefined) { const stepPattern = step.pattern || getActiveStepMarker(); @@ -308,7 +308,7 @@ async function renderCurrentStep() { currentTour, currentStep - 1, false, - false + false, ); const suffix = stepLabel ? ` (${stepLabel})` : ""; content += `← [Previous${suffix}](command:codetour.previousTourStep "Navigate to previous step")`; @@ -319,7 +319,7 @@ async function renderCurrentStep() { const tourTitle = getTourTitle(previousTour); const argsContent = encodeURIComponent( - JSON.stringify([previousTour.title]) + JSON.stringify([previousTour.title]), ); content += `← [Previous Tour (${tourTitle})](command:codetour.startTourByTitle?${argsContent} "Navigate to previous tour")`; } @@ -331,7 +331,7 @@ async function renderCurrentStep() { currentTour, currentStep + 1, false, - false + false, ); const suffix = stepLabel ? ` (${stepLabel})` : ""; content += `${prefix}[Next${suffix}](command:codetour.nextTourStep "Navigate to next step") →`; @@ -340,7 +340,7 @@ async function renderCurrentStep() { if (nextTour) { const tourTitle = getTourTitle(nextTour); const argsContent = encodeURIComponent( - JSON.stringify([nextTour.title]) + JSON.stringify([nextTour.title]), ); content += `${prefix}[Next Tour (${tourTitle})](command:codetour.finishTour?${argsContent} "Start next tour")`; } else { @@ -353,7 +353,7 @@ async function renderCurrentStep() { content, label, store.activeTour!.thread!, - mode + mode, ); // @ts-ignore @@ -382,7 +382,7 @@ async function renderCurrentStep() { step.selection.start.line - 1, step.selection.start.character - 1, step.selection.end.line - 1, - step.selection.end.character - 1 + step.selection.end.character - 1, ); } else { selection = new Selection(range.start, range.end); @@ -402,7 +402,7 @@ async function renderCurrentStep() { await commands.executeCommand(commandName); } catch { window.showErrorMessage( - `The current tour step is attempting to focus a view which isn't available: ${step.view}. Please check the tour and try again.` + `The current tour step is attempting to focus a view which isn't available: ${step.view}. Please check the tour and try again.`, ); } } @@ -431,7 +431,7 @@ async function renderCurrentStep() { async function showDocument(uri: Uri, range: Range, selection?: Selection) { const document = window.visibleTextEditors.find( - (editor) => editor.document.uri.toString() === uri.toString() + (editor) => editor.document.uri.toString() === uri.toString(), ) || (await window.showTextDocument(uri, { preserveFocus: true })); // TODO: Figure out how to force focus when navigating @@ -470,13 +470,13 @@ export function registerPlayerModule(context: ExtensionContext) { step.directory, step.view, ]), - ] + ] : null, ], () => { if (store.activeTour) { renderCurrentStep(); } - } + }, ); } diff --git a/Source/player/status.ts b/Source/player/status.ts index 4800012..3d67506 100644 --- a/Source/player/status.ts +++ b/Source/player/status.ts @@ -9,12 +9,12 @@ import { getTourTitle } from "../utils"; function createCurrentTourItem() { const currentTourItem = vscode.window.createStatusBarItem( - vscode.StatusBarAlignment.Left + vscode.StatusBarAlignment.Left, ); currentTourItem.command = `${EXTENSION_NAME}.resumeTour`; currentTourItem.color = new vscode.ThemeColor( - "statusBarItem.prominentForeground" + "statusBarItem.prominentForeground", ); currentTourItem.show(); @@ -31,7 +31,7 @@ export function registerStatusBar() { store.activeTour.step, store.activeTour.tour.title, store.activeTour.tour.steps.length, - ] + ] : null, store.isRecording, ], @@ -47,12 +47,10 @@ export function registerStatusBar() { currentTourItem.text = `${prefix}CodeTour: #${ store.activeTour.step + 1 } of ${store.activeTour.tour.steps.length} (${tourTitle})`; - } else { - if (currentTourItem) { - currentTourItem.dispose(); - currentTourItem = null; - } + } else if (currentTourItem) { + currentTourItem.dispose(); + currentTourItem = null; } - } + }, ); } diff --git a/Source/player/tree/index.ts b/Source/player/tree/index.ts index bcaa477..be2db19 100644 --- a/Source/player/tree/index.ts +++ b/Source/player/tree/index.ts @@ -11,8 +11,8 @@ import { TreeItem, window, } from "vscode"; -import { EXTENSION_NAME } from "../../constants"; import { generatePreviewContent } from ".."; +import { EXTENSION_NAME } from "../../constants"; import { store } from "../../store"; import { CodeTourNode, CodeTourStepNode } from "./nodes"; @@ -42,12 +42,12 @@ class CodeTourTreeProvider implements TreeDataProvider, Disposable { step.markerTitle, step.description, ]), - ] + ] : null, ], () => { this._onDidChangeTreeData.fire(undefined); - } + }, ); } @@ -59,20 +59,20 @@ class CodeTourTreeProvider implements TreeDataProvider, Disposable { return undefined; } else { const tours = store.tours.map( - (tour) => new CodeTourNode(tour, this.extensionPath) + (tour) => new CodeTourNode(tour, this.extensionPath), ); if ( store.activeTour && !store.tours.find( - (tour) => tour.id === store.activeTour?.tour.id + (tour) => tour.id === store.activeTour?.tour.id, ) ) { tours.unshift( new CodeTourNode( store.activeTour.tour, - this.extensionPath - ) + this.extensionPath, + ), ); } @@ -98,7 +98,7 @@ class CodeTourTreeProvider implements TreeDataProvider, Disposable { return [item]; } else { return element.tour.steps.map( - (_, index) => new CodeTourStepNode(element.tour, index) + (_, index) => new CodeTourStepNode(element.tour, index), ); } } @@ -117,7 +117,7 @@ class CodeTourTreeProvider implements TreeDataProvider, Disposable { async resolveTreeItem(element: TreeItem): Promise { if (element instanceof CodeTourStepNode) { const content = generatePreviewContent( - element.tour.steps[element.stepNumber].description + element.tour.steps[element.stepNumber].description, ); const tooltip = new MarkdownString(content); @@ -156,8 +156,8 @@ export function registerTreeProvider(extensionPath: string) { treeView.reveal( new CodeTourStepNode( store.activeTour!.tour, - store.activeTour!.step - ) + store.activeTour!.step, + ), ); }, 300); } @@ -169,7 +169,7 @@ export function registerTreeProvider(extensionPath: string) { store.activeTour.tour.title, store.activeTour.tour.steps.map((step) => [step.title]), store.activeTour.step, - ] + ] : null, ], () => { @@ -188,6 +188,6 @@ export function registerTreeProvider(extensionPath: string) { // to de-select the step node once the tour ends. treeView.message = undefined; } - } + }, ); } diff --git a/Source/player/tree/nodes.ts b/Source/player/tree/nodes.ts index a834a11..40d0e88 100644 --- a/Source/player/tree/nodes.ts +++ b/Source/player/tree/nodes.ts @@ -24,19 +24,16 @@ function isRecording(tour: CodeTour) { const completeIcon = new ThemeIcon( "check", // @ts-ignore - new ThemeColor("terminal.ansiGreen") + new ThemeColor("terminal.ansiGreen"), ); export class CodeTourNode extends TreeItem { - constructor( - public tour: CodeTour, - extensionPath: string - ) { + constructor(public tour: CodeTour, extensionPath: string) { super( tour.title!, isRecording(tour) ? TreeItemCollapsibleState.Expanded - : TreeItemCollapsibleState.Collapsed + : TreeItemCollapsibleState.Collapsed, ); this.tooltip = tour.description; @@ -64,18 +61,15 @@ export class CodeTourNode extends TreeItem { this.iconPath = isRecording(tour) ? new ThemeIcon("record") : isActive - ? new ThemeIcon("play-circle") - : progress.isComplete(tour) - ? completeIcon - : new ThemeIcon("location"); + ? new ThemeIcon("play-circle") + : progress.isComplete(tour) + ? completeIcon + : new ThemeIcon("location"); } } export class CodeTourStepNode extends TreeItem { - constructor( - public tour: CodeTour, - public stepNumber: number - ) { + constructor(public tour: CodeTour, public stepNumber: number) { super(getStepLabel(tour, stepNumber)); const step = tour.steps[stepNumber]; @@ -104,7 +98,7 @@ export class CodeTourStepNode extends TreeItem { resourceUri = getFileUri( step.directory || step.file!, - resourceRoot + resourceRoot, ); } else { resourceUri = CONTENT_URI; @@ -139,7 +133,7 @@ export class CodeTourStepNode extends TreeItem { if (data.length > 1) { this.iconPath = new ThemeIcon( data[0], - new ThemeColor(data[1]) + new ThemeColor(data[1]), ); } else { this.iconPath = new ThemeIcon(data[0]); diff --git a/Source/recorder/commands.ts b/Source/recorder/commands.ts index ab7dc85..9e7c490 100644 --- a/Source/recorder/commands.ts +++ b/Source/recorder/commands.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { action, comparer, runInAction } from "mobx"; import * as path from "path"; +import { action, comparer, runInAction } from "mobx"; import * as vscode from "vscode"; import { workspace } from "vscode"; import { EXTENSION_NAME, FS_SCHEME_CONTENT } from "../constants"; -import { api, RefType } from "../git"; +import { RefType, api } from "../git"; import { CodeTourComment } from "../player"; import { CodeTourNode, CodeTourStepNode } from "../player/tree/nodes"; import { CodeTour, CodeTourStep, store } from "../store"; @@ -73,7 +73,7 @@ export function registerRecorderCommands() { async function writeTourFile( workspaceRoot: vscode.Uri, title: string | vscode.Uri, - ref?: string + ref?: string, ): Promise { const uri = typeof title === "string" @@ -112,7 +112,7 @@ export function registerRecorderCommands() { const REENTER_TITLE_RESPONSE = "Re-enter title"; async function recordTourInternal( tourTitle: string | vscode.Uri, - workspaceRoot?: vscode.Uri + workspaceRoot?: vscode.Uri, ) { if (!workspaceRoot) { workspaceRoot = workspace.workspaceFolders![0].uri; @@ -139,21 +139,21 @@ export function registerRecorderCommands() { if (typeof tourTitle === "string") { const tourExists = await checkIfTourExists( workspaceRoot, - tourTitle + tourTitle, ); if (tourExists) { const response = await vscode.window.showErrorMessage( `This workspace already includes a tour with the title "${tourTitle}."`, REENTER_TITLE_RESPONSE, - "Overwrite existing tour" + "Overwrite existing tour", ); if (response === REENTER_TITLE_RESPONSE) { return vscode.commands.executeCommand( `${EXTENSION_NAME}.recordTour`, workspaceRoot, - tourTitle + tourTitle, ); } else if (!response) { // If the end-user closes the error @@ -178,7 +178,7 @@ export function registerRecorderCommands() { startCodeTour(tour, 0, workspaceRoot, true); vscode.window.showInformationMessage( - "CodeTour recording started! Begin creating steps by opening a file, clicking the + button to the left of a line of code, and then adding the appropriate comments." + "CodeTour recording started! Begin creating steps by opening a file, clicking the + button to the left of a line of code, and then adding the appropriate comments.", ); } @@ -227,13 +227,13 @@ export function registerRecorderCommands() { if ( await vscode.window.showInformationMessage( "Would you like to export this tour?", - "Export Tour" + "Export Tour", ) ) { const content = await exportTour(tour); vscode.workspace.fs.writeFile( uri, - Buffer.from(content) + Buffer.from(content), ); } } @@ -243,7 +243,7 @@ export function registerRecorderCommands() { }); inputBox.show(); - } + }, ); function getStepSelection() { @@ -318,12 +318,12 @@ export function registerRecorderCommands() { vscode.commands.executeCommand( "setContext", EDITING_KEY, - false + false, ); } saveTour(tour); - }) + }), ); vscode.commands.registerCommand( @@ -345,12 +345,12 @@ export function registerRecorderCommands() { vscode.commands.executeCommand( "setContext", EDITING_KEY, - false + false, ); } saveTour(tour); - }) + }), ); vscode.commands.registerTextEditorCommand( @@ -362,7 +362,7 @@ export function registerRecorderCommands() { const workspaceRoot = getActiveWorkspacePath(); const file = getRelativePath( workspaceRoot, - editor.document.uri.path + editor.document.uri.path, ); tour.steps.splice(stepNumber, 0, { @@ -376,12 +376,12 @@ export function registerRecorderCommands() { vscode.commands.executeCommand( "setContext", EDITING_KEY, - false + false, ); } saveTour(tour); - }) + }), ); vscode.commands.registerCommand( @@ -449,7 +449,7 @@ export function registerRecorderCommands() { saveTour(tour); - let label = `Step #${stepNumber + 1} of ${tour.steps.length}`; + const label = `Step #${stepNumber + 1} of ${tour.steps.length}`; const contextValues = []; if (tour.steps.length > 1) { @@ -466,10 +466,10 @@ export function registerRecorderCommands() { reply.text, label, thread!, - vscode.CommentMode.Preview + vscode.CommentMode.Preview, ), ]; - }) + }), ); vscode.commands.registerCommand( @@ -480,12 +480,12 @@ export function registerRecorderCommands() { await vscode.commands.executeCommand( "setContext", "codetour:recording", - true + true, ); await vscode.commands.executeCommand( "setContext", EDITING_KEY, - true + true, ); if (node instanceof CodeTourNode) { @@ -496,17 +496,17 @@ export function registerRecorderCommands() { startCodeTour( store.activeTour!.tour, store.activeTour!.step, - store.activeTour.workspaceRoot + store.activeTour.workspaceRoot, ); } - } + }, ); vscode.commands.registerCommand( `${EXTENSION_NAME}.editTourAtStep`, async (node: CodeTourStepNode) => { startCodeTour(node.tour, node.stepNumber, undefined, true); - } + }, ); vscode.commands.registerCommand( @@ -517,7 +517,7 @@ export function registerRecorderCommands() { await vscode.commands.executeCommand( "setContext", "codetour:recording", - false + false, ); if (node instanceof CodeTourNode) { @@ -528,10 +528,10 @@ export function registerRecorderCommands() { startCodeTour( store.activeTour!.tour, store.activeTour!.step, - store.activeTour.workspaceRoot + store.activeTour.workspaceRoot, ); } - } + }, ); vscode.commands.registerCommand( @@ -547,7 +547,7 @@ export function registerRecorderCommands() { delete tour.isPrimary; saveTour(tour); }); - } + }, ); vscode.commands.registerCommand( @@ -556,7 +556,7 @@ export function registerRecorderCommands() { const primaryTour = node.tour; delete primaryTour.isPrimary; saveTour(primaryTour); - } + }, ); vscode.commands.registerCommand( @@ -585,7 +585,7 @@ export function registerRecorderCommands() { store.isEditing = false; vscode.commands.executeCommand("setContext", EDITING_KEY, false); await saveTour(store.activeTour!.tour); - } + }, ); async function updateTourProperty(tour: CodeTour, property: string) { @@ -608,7 +608,7 @@ export function registerRecorderCommands() { function moveStep( movement: number, - node: CodeTourStepNode | CodeTourComment + node: CodeTourStepNode | CodeTourComment, ) { let tour: CodeTour, stepNumber: number; @@ -641,17 +641,17 @@ export function registerRecorderCommands() { vscode.commands.registerCommand( `${EXTENSION_NAME}.moveTourStepBack`, - moveStep.bind(null, -1) + moveStep.bind(null, -1), ); vscode.commands.registerCommand( `${EXTENSION_NAME}.moveTourStepForward`, - moveStep.bind(null, 1) + moveStep.bind(null, 1), ); vscode.commands.registerCommand( `${EXTENSION_NAME}.changeTourDescription`, - (node: CodeTourNode) => updateTourProperty(node.tour, "description") + (node: CodeTourNode) => updateTourProperty(node.tour, "description"), ); vscode.commands.registerCommand( @@ -671,7 +671,7 @@ export function registerRecorderCommands() { saveTour(tour); }); } - } + }, ); vscode.commands.registerCommand( @@ -692,7 +692,7 @@ export function registerRecorderCommands() { } saveTour(node.tour); - } + }, ); vscode.commands.registerCommand( @@ -713,7 +713,7 @@ export function registerRecorderCommands() { } saveTour(node.tour); - } + }, ); vscode.commands.registerCommand( @@ -732,7 +732,7 @@ export function registerRecorderCommands() { } saveTour(store.activeTour!.tour); - } + }, ); vscode.commands.registerCommand( @@ -744,12 +744,12 @@ export function registerRecorderCommands() { store.activeTour.workspaceRoot ? store.activeTour.workspaceRoot : workspace.getWorkspaceFolder( - vscode.Uri.parse(node.tour.id) - )?.uri; + vscode.Uri.parse(node.tour.id), + )?.uri; if (!workspaceRoot) { return vscode.window.showErrorMessage( - "You can't change the git ref of an embedded tour file." + "You can't change the git ref of an embedded tour file.", ); } @@ -763,7 +763,7 @@ export function registerRecorderCommands() { } saveTour(node.tour); - } + }, ); vscode.commands.registerCommand( @@ -780,11 +780,11 @@ export function registerRecorderCommands() { if ( await vscode.window.showInformationMessage( `Are you sure your want to delete the ${messageSuffix}?`, - `Delete ${buttonSuffix}` + `Delete ${buttonSuffix}`, ) ) { const tourIds = (additionalNodes || [node]).map( - (node) => node.tour.id + (node) => node.tour.id, ); if ( @@ -799,14 +799,14 @@ export function registerRecorderCommands() { vscode.workspace.fs.delete(uri); }); } - } + }, ); vscode.commands.registerCommand( `${EXTENSION_NAME}.deleteTourStep`, async ( node: CodeTourStepNode | CodeTourComment, - additionalNodes: CodeTourStepNode[] + additionalNodes: CodeTourStepNode[], ) => { let tour: CodeTour, steps: number[]; let messageSuffix = "selected step"; @@ -833,14 +833,14 @@ export function registerRecorderCommands() { if ( await vscode.window.showInformationMessage( `Are you sure your want to delete the ${messageSuffix}?`, - `Delete ${buttonSuffix}` + `Delete ${buttonSuffix}`, ) ) { steps.forEach((step) => tour.steps.splice(step, 1)); if (store.activeTour && store.activeTour.tour.id === tour.id) { const previousSteps = steps.filter( - (step) => step <= store.activeTour!.step + (step) => step <= store.activeTour!.step, ); if ( previousSteps.length > 0 && @@ -865,7 +865,7 @@ export function registerRecorderCommands() { saveTour(tour); } - } + }, ); interface GitRefQuickPickItem extends vscode.QuickPickItem { @@ -873,7 +873,7 @@ export function registerRecorderCommands() { } async function promptForTourRef( - workspaceRoot: vscode.Uri + workspaceRoot: vscode.Uri, ): Promise { // If for some reason the Git extension isn't available, // then we won't be able to ask the user to select a git ref. @@ -890,7 +890,7 @@ export function registerRecorderCommands() { } const currentBranch = repository.state.HEAD!.name; - let items: GitRefQuickPickItem[] = [ + const items: GitRefQuickPickItem[] = [ { label: "$(circle-slash) None", description: @@ -931,7 +931,7 @@ export function registerRecorderCommands() { items, { placeHolder: "Select the Git ref to associate the tour with:", - } + }, ); if (response) { diff --git a/Source/recorder/completionProvider.ts b/Source/recorder/completionProvider.ts index 8cf2188..e1bf16a 100644 --- a/Source/recorder/completionProvider.ts +++ b/Source/recorder/completionProvider.ts @@ -8,7 +8,7 @@ const COMMANDS = [ label: "Navigate to tour step", detail: "Navigates the end-user to the specified step in the current tour.", insertText: new vscode.SnippetString( - "codetour.navigateToStep?" + "codetour.navigateToStep?", ).appendPlaceholder("stepNumber"), }, { @@ -27,7 +27,7 @@ const COMMANDS = [ label: "Run task", detail: "Runs a task that's defined by the current workspace.", insertText: new vscode.SnippetString( - 'workbench.action.tasks.runTask?["' + 'workbench.action.tasks.runTask?["', ) .appendPlaceholder("taskName") .appendText('"]'), @@ -58,7 +58,7 @@ class CodeTourCompletionProvider implements vscode.CompletionItemProvider { document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, - context: vscode.CompletionContext + context: vscode.CompletionContext, ): vscode.ProviderResult { const line = document.lineAt(position); if (line.text.includes("command:")) { @@ -71,6 +71,6 @@ export function registerCompletionProvider() { vscode.languages.registerCompletionItemProvider( { scheme: "comment" }, new CodeTourCompletionProvider(), - ":" + ":", ); } diff --git a/Source/recorder/watcher.ts b/Source/recorder/watcher.ts index 3949114..5171d3f 100644 --- a/Source/recorder/watcher.ts +++ b/Source/recorder/watcher.ts @@ -16,7 +16,7 @@ const changeWatcher = async (e: vscode.TextDocumentChangeEvent) => { const impactedSteps = store.activeEditorSteps!.filter( ([, step, , line]) => step.pattern && - e.contentChanges.some((change) => line === change.range.start.line) + e.contentChanges.some((change) => line === change.range.start.line), ); if (impactedSteps.length === 0) { @@ -25,7 +25,7 @@ const changeWatcher = async (e: vscode.TextDocumentChangeEvent) => { await Promise.all( e.contentChanges.map(async () => { - for (let [tour, step, , line] of impactedSteps) { + for (const [tour, step, , line] of impactedSteps) { const changedText = e.document.lineAt(line!).text; // If the text is empty, then that means the user @@ -45,7 +45,7 @@ const changeWatcher = async (e: vscode.TextDocumentChangeEvent) => { await debouncedSaveTour(tour); } } - }) + }), ); }; diff --git a/Source/store/actions.ts b/Source/store/actions.ts index df569d6..d15c567 100644 --- a/Source/store/actions.ts +++ b/Source/store/actions.ts @@ -2,10 +2,10 @@ // Licensed under the MIT License. import { - commands, EventEmitter, Memento, Uri, + commands, window, workspace, } from "vscode"; @@ -44,9 +44,9 @@ export function startCodeTour( tour: CodeTour, stepNumber?: number, workspaceRoot?: Uri, - startInEditMode: boolean = false, - canEditTour: boolean = true, - tours?: CodeTour[] + startInEditMode = false, + canEditTour = true, + tours?: CodeTour[], ) { startPlayer(); @@ -79,7 +79,7 @@ export function startCodeTour( export async function selectTour( tours: CodeTour[], workspaceRoot?: Uri, - step: number = 0 + step = 0, ): Promise { const items: any[] = tours.map((tour) => ({ label: tour.title!, @@ -104,7 +104,7 @@ export async function selectTour( return false; } -export async function endCurrentCodeTour(fireEvent: boolean = true) { +export async function endCurrentCodeTour(fireEvent = true) { if (fireEvent) { _onDidEndTour.fire(store.activeTour!.tour); } @@ -160,7 +160,7 @@ function isLiveShareWorkspace(uri: Uri) { export async function promptForTour( globalState: Memento, workspaceRoot: Uri = getWorkspaceKey(), - tours: CodeTour[] = store.tours + tours: CodeTour[] = store.tours, ): Promise { const key = `${EXTENSION_NAME}:${workspaceRoot}`; if ( @@ -177,7 +177,7 @@ export async function promptForTour( if ( await window.showInformationMessage( "This workspace has guided tours you can take to get familiar with the codebase.", - "Start CodeTour" + "Start CodeTour", ) ) { startDefaultTour(workspaceRoot, tours); @@ -190,7 +190,7 @@ export async function promptForTour( export async function startDefaultTour( workspaceRoot: Uri = getWorkspaceKey(), tours: CodeTour[] = store.tours, - step: number = 0 + step = 0, ): Promise { if (tours.length === 0) { return false; @@ -207,7 +207,7 @@ export async function startDefaultTour( workspaceRoot, false, undefined, - tours + tours, ); return true; } else { @@ -231,7 +231,7 @@ export async function exportTour(tour: CodeTour) { const stepFileUri = await getStepFileUri( step, workspaceRoot, - tour.ref + tour.ref, ); const contents = await readUriContents(stepFileUri); @@ -241,7 +241,7 @@ export async function exportTour(tour: CodeTour) { ...step, contents, }; - }) + }), ); } diff --git a/Source/store/provider.ts b/Source/store/provider.ts index bc6a9a6..d529171 100644 --- a/Source/store/provider.ts +++ b/Source/store/provider.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +import * as os from "os"; import * as jexl from "jexl"; import { comparer, runInAction, set } from "mobx"; -import * as os from "os"; import * as vscode from "vscode"; import { CodeTour, store } from "."; import { EXTENSION_NAME, VSCODE_DIRECTORY } from "../constants"; @@ -51,7 +51,7 @@ export async function discoverTours(): Promise { } return tours; - }) + }), ); runInAction(() => { @@ -59,12 +59,12 @@ export async function discoverTours(): Promise { .flat() .sort((a, b) => a.title.localeCompare(b.title)) .filter( - (tour) => !tour.when || jexl.evalSync(tour.when, TOUR_CONTEXT) + (tour) => !tour.when || jexl.evalSync(tour.when, TOUR_CONTEXT), ); if (store.activeTour) { const tour = store.tours.find( - (tour) => tour.id === store.activeTour!.tour.id + (tour) => tour.id === store.activeTour!.tour.id, ); if (tour) { @@ -88,7 +88,7 @@ export async function discoverTours(): Promise { } async function discoverMainTours( - workspaceUri: vscode.Uri + workspaceUri: vscode.Uri, ): Promise { const tours = await Promise.all( MAIN_TOUR_FILES.map(async (tourFile) => { @@ -100,7 +100,7 @@ async function discoverMainTours( tour.id = decodeURIComponent(uri.toString()); return tour; } catch {} - }) + }), ); return tours.filter((tour) => tour); @@ -119,7 +119,7 @@ async function readTourDirectory(uri: vscode.Uri): Promise { } else { return readTourDirectory(fileUri); } - }) + }), ); // @ts-ignore @@ -130,7 +130,7 @@ async function readTourDirectory(uri: vscode.Uri): Promise { } async function readTourFile( - tourUri: vscode.Uri + tourUri: vscode.Uri, ): Promise { try { const tourContent = await readUriContents(tourUri); @@ -145,7 +145,7 @@ async function discoverSubTours(workspaceUri: vscode.Uri): Promise { SUB_TOUR_DIRECTORIES.map((directory) => { const uri = vscode.Uri.joinPath(workspaceUri, directory); return readTourDirectory(uri); - }) + }), ); return tours.flat(); @@ -154,7 +154,7 @@ async function discoverSubTours(workspaceUri: vscode.Uri): Promise { vscode.workspace.onDidChangeWorkspaceFolders(discoverTours); const watcher = vscode.workspace.createFileSystemWatcher( - `**/{${SUB_TOUR_DIRECTORIES.join(",")}}/**/*.tour` + `**/{${SUB_TOUR_DIRECTORIES.join(",")}}/**/*.tour`, ); watcher.onDidChange(discoverTours); diff --git a/Source/store/storage.ts b/Source/store/storage.ts index 3439c8d..468feba 100644 --- a/Source/store/storage.ts +++ b/Source/store/storage.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { observable } from "mobx"; -import { commands, ExtensionContext, Uri, workspace } from "vscode"; +import { ExtensionContext, Uri, commands, workspace } from "vscode"; import { CodeTour, store } from "."; const CODETOUR_PROGRESS_KEY = "codetour:progress"; @@ -24,7 +24,7 @@ export function initializeStorage(context: ExtensionContext) { progress = { async update() { const progress = store.progress.find( - ([id]) => store.activeTour?.tour.id === id + ([id]) => store.activeTour?.tour.id === id, ); if (progress && !progress![1].includes(store.activeTour!.step)) { @@ -39,7 +39,7 @@ export function initializeStorage(context: ExtensionContext) { commands.executeCommand("setContext", "codetour:hasProgress", true); return context.globalState.update( CODETOUR_PROGRESS_KEY, - store.progress + store.progress, ); }, isComplete(tour: CodeTour, stepNumber?: number): boolean { @@ -54,17 +54,17 @@ export function initializeStorage(context: ExtensionContext) { commands.executeCommand( "setContext", "codetour:hasProgress", - false + false, ); store.progress = tour ? store.progress.filter( - (tourProgress) => tourProgress[0] !== tour.id - ) + (tourProgress) => tourProgress[0] !== tour.id, + ) : []; return context.globalState.update( CODETOUR_PROGRESS_KEY, - store.progress + store.progress, ); }, }; @@ -73,7 +73,7 @@ export function initializeStorage(context: ExtensionContext) { context.globalState.setKeysForSync([CODETOUR_PROGRESS_KEY]); const workspaceHasProgress = store.progress.some(([id]) => - workspace.getWorkspaceFolder(Uri.parse(id)) + workspace.getWorkspaceFolder(Uri.parse(id)), ); if (workspaceHasProgress) { diff --git a/Source/utils.ts b/Source/utils.ts index d2358db..90262b9 100644 --- a/Source/utils.ts +++ b/Source/utils.ts @@ -12,8 +12,8 @@ const HEADING_PATTERN = /^#+\s*(.*)/; export function getStepLabel( tour: CodeTour, stepNumber: number, - includeStepNumber: boolean = true, - defaultToFileName: boolean = true + includeStepNumber = true, + defaultToFileName = true, ) { const step = tour.steps[stepNumber]; @@ -69,7 +69,7 @@ export function getFileUri(file: string, workspaceRoot?: Uri) { export async function getStepFileUri( step: CodeTourStep, workspaceRoot?: Uri, - ref?: string + ref?: string, ): Promise { let uri; if (step.contents) { @@ -185,14 +185,14 @@ async function updateMarkerTitleForStep(tour: CodeTour, stepNumber: number) { const uri = await getStepFileUri( tour.steps[stepNumber], getWorkspaceUri(tour), - tour.ref + tour.ref, ); const document = await workspace.openTextDocument(uri); const stepMarkerPrefix = getStepMarkerPrefix(tour); const markerPattern = new RegExp( - `${stepMarkerPrefix}\\.${stepNumber + 1}\\s*[-:]\\s*(.*)` + `${stepMarkerPrefix}\\.${stepNumber + 1}\\s*[-:]\\s*(.*)`, ); const match = document.getText().match(markerPattern);