All files / src editorTypes.ts

100% Statements 8/8
100% Branches 4/4
100% Functions 2/2
100% Lines 6/6

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        4x             30x 30x 24x 20x       8x    
import * as path from 'path';
 
export type FileType = 'markdown' | 'excalidraw' | 'csv';
 
export const CUSTOM_EDITOR_VIEW_TYPES: Record<FileType, string> = {
  markdown: 'vibeDocuments.markdownEditor',
  csv: 'vibeDocuments.csvEditor',
  excalidraw: 'vibeDocuments.excalidrawEditor',
};
 
export function inferFileType(fsPath: string): FileType {
  const ext = path.extname(fsPath).toLowerCase();
  if (ext === '.csv') return 'csv';
  if (ext === '.excalidraw') return 'excalidraw';
  return 'markdown';
}
 
export function getCustomEditorViewType(fsPath: string) {
  return CUSTOM_EDITOR_VIEW_TYPES[inferFileType(fsPath)];
}