import * as vscode from 'vscode' ; import * as path from 'path' ; export let doc ; export let editor ; export let documentEol ; export let platformEol ; export async function open ( docUri ) { try { doc = await vscode . workspace . openTextDocument ( docUri ) ; editor = await vscode . window . showTextDocument ( doc ) ; } catch ( e ) { console . error ( e ) ; throw e ; } } export function getExtensionId ( ) { const pjson = require ( '../../package.json' ) ; return `${ pjson . publisher }.${ pjson . name }` ; } export const testFolderPath = path . resolve ( __dirname , '..' , '..' , 'testFixture' ) ; export const getDocPath = ( p ) : string => { return path . resolve ( __dirname , '../../testFixture' , p ) ; } ; export const getDocUri = ( p ) : vscode . Uri => { return vscode . Uri . file ( getDocPath ( p ) ) ; } ; export async function setTestContent ( content ) { const all = new vscode . Range ( doc . positionAt ( 0 ) , doc . positionAt ( doc . getText ( ) . length ) ) ; return editor . edit ( ( eb ) => eb . replace ( all , content ) ) ; }