import { Connection } from 'vscode-languageserver/node' ; import { YamlCommands } from '../../commands' ; import { CommandExecutor } from '../../languageserver/commandExecutor' ; import { URI } from 'vscode-uri' ; export function registerCommands ( commandExecutor , connection ) { commandExecutor . registerCommand ( YamlCommands . JUMP_TO_SCHEMA , async ( uri ) => { if ( ! uri ) { return ; } if ( ! uri . startsWith ( 'file' ) && ! /^[a-z]:[\\/]/i . test ( uri ) ) { const origUri = URI . parse ( uri ) ; const customUri = URI . from ( { scheme : 'json-schema' , authority : origUri . authority , path : origUri . path . endsWith ( '.json' ) ? origUri . path : origUri . path + '.json' , fragment : uri , } ) ; uri = customUri . toString ( ) ; } if ( /^[a-z]:[\\/]/i . test ( uri ) ) { const winUri = URI . file ( uri ) ; uri = winUri . toString ( ) ; } const result = await connection . window . showDocument ( { uri : uri , external : false , takeFocus : true } ) ; if ( ! result ) { connection . window . showErrorMessage ( `Cannot open ${ uri }` ) ; } } ) ; }