@@ -948,27 +948,51 @@ export function openDocs(ctx: CtxInit): Cmd {
948948 const position = editor . selection . active ;
949949 const textDocument = { uri : editor . document . uri . toString ( ) } ;
950950
951- const doclinks = await client . sendRequest ( ra . openDocs , { position, textDocument } ) ;
951+ const docLinks = await client . sendRequest ( ra . openDocs , { position, textDocument } ) ;
952+ log . debug ( docLinks ) ;
952953
953954 let fileType = vscode . FileType . Unknown ;
954- if ( typeof doclinks . local === "string" ) {
955+ if ( docLinks . local !== undefined ) {
955956 try {
956- fileType = ( await vscode . workspace . fs . stat ( vscode . Uri . parse ( doclinks . local ) ) ) . type ;
957+ fileType = ( await vscode . workspace . fs . stat ( vscode . Uri . parse ( docLinks . local ) ) ) . type ;
957958 } catch ( e ) {
958959 log . debug ( "stat() threw error. Falling back to web version" , e ) ;
959960 }
960961 }
961962
962- let doclink ;
963- if ( fileType & vscode . FileType . File ) {
964- // file does exist locally
965- doclink = doclinks . local ;
966- } else {
967- doclink = doclinks . web ;
963+ let docLink = fileType & vscode . FileType . File ? docLinks . local : docLinks . web ;
964+ if ( docLink ) {
965+ // instruct vscode to handle the vscode-remote link directly
966+ if ( docLink . startsWith ( "vscode-remote://" ) ) {
967+ docLink = docLink . replace ( "vscode-remote://" , "vscode://vscode-remote/" ) ;
968+ }
969+ const docUri = vscode . Uri . parse ( docLink ) ;
970+ await vscode . env . openExternal ( docUri ) ;
971+ }
972+ } ;
973+ }
974+
975+ export function openExternalDocs ( ctx : CtxInit ) : Cmd {
976+ return async ( ) => {
977+ const editor = vscode . window . activeTextEditor ;
978+ if ( ! editor ) {
979+ return ;
968980 }
981+ const client = ctx . client ;
982+
983+ const position = editor . selection . active ;
984+ const textDocument = { uri : editor . document . uri . toString ( ) } ;
969985
970- if ( doclink != null ) {
971- await vscode . env . openExternal ( vscode . Uri . parse ( doclink ) ) ;
986+ const docLinks = await client . sendRequest ( ra . openDocs , { position, textDocument } ) ;
987+
988+ let docLink = docLinks . web ;
989+ if ( docLink ) {
990+ // instruct vscode to handle the vscode-remote link directly
991+ if ( docLink . startsWith ( "vscode-remote://" ) ) {
992+ docLink = docLink . replace ( "vscode-remote://" , "vscode://vscode-remote/" ) ;
993+ }
994+ const docUri = vscode . Uri . parse ( docLink ) ;
995+ await vscode . env . openExternal ( docUri ) ;
972996 }
973997 } ;
974998}
0 commit comments