All files / src codeLensProvider.ts

100% Statements 5/5
100% Branches 1/1
100% Functions 2/2
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36          2x                               41x     11x 11x 11x                  
import * as vscode from 'vscode';
import type { FileType } from './editorTypes';
 
export type { FileType } from './editorTypes';
 
const FILE_TYPE_CONFIG: Record<FileType, { title: string; command: string }> = {
  markdown: {
    title: '$(open-preview)  Open Vibe Preview',
    command: 'vibeDocuments.showPreview',
  },
  excalidraw: {
    title: '$(open-preview)  Open Excalidraw Editor',
    command: 'vibeDocuments.showExcalidrawPreview',
  },
  csv: {
    title: '$(open-preview)  Open CSV Preview',
    command: 'vibeDocuments.showCsvPreview',
  },
};
 
export class PreviewCodeLensProvider implements vscode.CodeLensProvider {
  constructor(private readonly fileType: FileType = 'markdown') {}
 
  provideCodeLenses(document: vscode.TextDocument): vscode.CodeLens[] {
    const config = FILE_TYPE_CONFIG[this.fileType];
    const range = new vscode.Range(0, 0, 0, 0);
    return [
      new vscode.CodeLens(range, {
        title: config.title,
        command: config.command,
        arguments: [document.uri],
      }),
    ];
  }
}