ryu1kn/vscode-partial-diff

View on GitHub
src/lib/adaptors/window.ts

Summary

Maintainability
A
0 mins
Test Coverage
F
33%
import * as vscode from 'vscode';
import TextEditor from './text-editor';
import {QuickPickItem, TextEditor as VsTextEditor} from 'vscode';

export default class WindowAdaptor {
    constructor(private readonly window: typeof vscode.window) {}

    get visibleTextEditors(): TextEditor[] {
        return this.window.visibleTextEditors.map((editor: VsTextEditor) => new TextEditor(editor));
    }

    async showQuickPick<T extends QuickPickItem>(items: T[]): Promise<T[] | undefined> {
        // @ts-ignore
        return this.window.showQuickPick(items, {canPickMany: true});
    }

    async showInformationMessage(message: string): Promise<string | undefined> {
        return this.window.showInformationMessage(message);
    }
}