@@ -948,27 +948,51 @@ export function openDocs(ctx: CtxInit): Cmd {
948
948
const position = editor . selection . active ;
949
949
const textDocument = { uri : editor . document . uri . toString ( ) } ;
950
950
951
- const doclinks = await client . sendRequest ( ra . openDocs , { position, textDocument } ) ;
951
+ const docLinks = await client . sendRequest ( ra . openDocs , { position, textDocument } ) ;
952
+ log . debug ( docLinks ) ;
952
953
953
954
let fileType = vscode . FileType . Unknown ;
954
- if ( typeof doclinks . local === "string" ) {
955
+ if ( docLinks . local !== undefined ) {
955
956
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 ;
957
958
} catch ( e ) {
958
959
log . debug ( "stat() threw error. Falling back to web version" , e ) ;
959
960
}
960
961
}
961
962
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 ;
968
980
}
981
+ const client = ctx . client ;
982
+
983
+ const position = editor . selection . active ;
984
+ const textDocument = { uri : editor . document . uri . toString ( ) } ;
969
985
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 ) ;
972
996
}
973
997
} ;
974
998
}
0 commit comments