@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Interface OperationsService

    Starts Operation-scoped framework work from somewhere that is not a command.

    A command handler is handed an OperationContext — cancellation, a scoped logger, a resource scope, progress. Plenty of real work starts elsewhere: a webview asks the host to do something over RPC, a tree view refreshes, an editor event fires. This is how that work gets the same context, rather than each caller improvising a signal and a progress call.

    It is not a second way to show progress. context.progress remains the only one; this is how you come by a context outside a handler.

    panel.rpc.onRequest('reindex', () =>
    operations.run('reindex', (context) =>
    context.progress.run({ title: 'Reindexing', cancellable: true }, (_report, signal) =>
    index.rebuild(signal)
    )
    )
    );
    interface OperationsService {
        run<T>(
            name: string,
            work: (context: OperationContext) => T | Promise<T>,
            options?: RunTaskOptions,
        ): Promise<T>;
    }
    Index
    • Runs work as an operation.

      The result and any rejection reach the caller untouched, exactly as for a command. Operation resources are disposed before the returned promise settles; cleanup failures are reported but do not replace that result.

      Type Parameters

      • T

      Parameters

      • name: string

        What the work is, for diagnostics and log fields

      • work: (context: OperationContext) => T | Promise<T>

        The work

      • Optionaloptions: RunTaskOptions

        Caller cancellation and deadline

      Returns Promise<T>