@@ -741,7 +741,7 @@ const DUMMY_CTX = { subscriptions: { add: (_unsubscribable: any) => void 0 } }
741741
742742export function activate ( ctx : sourcegraph . ExtensionContext = DUMMY_CTX ) : void {
743743 async function afterActivate ( ) : Promise < void > {
744- if ( Math . random ( ) < 0 ) {
744+ if ( ! sourcegraph . configuration . get ( ) . get ( 'lspclient' ) ) {
745745 const address = sourcegraph . configuration . get < Settings > ( ) . get ( 'go.serverUrl' )
746746 if ( address ) {
747747 ctx . subscriptions . add ( registerFeedbackButton ( { languageID : 'go' , sourcegraph, isPrecise : true } ) )
@@ -808,16 +808,31 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
808808 } ,
809809 } ) ,
810810 documentSelector : [ { language : 'go' } ] ,
811- // clientToServerURI: uri => ..., // optional
812- // serverToClientURI: uri => ..., // optional
813- initializationOptions : ( url : URL ) => {
814- url . hash = ''
811+ clientToServerURI : ( uri : URL ) => new URL ( `file:///${ uri . hash . slice ( 1 ) } ` ) ,
812+ serverToClientURI : ( uri , currentRootURI ) => {
813+ if ( ! currentRootURI ) {
814+ return uri
815+ }
816+
817+ if ( / ^ f i l e : \/ \/ \/ / . test ( uri . href ) ) {
818+ // The definition is in a file in the same repo
819+ const docURL = new URL ( currentRootURI . href )
820+ docURL . hash = uri . href . slice ( 'file:///' . length )
821+ return docURL
822+ }
823+ return uri
824+ } ,
825+ additionalInitializationOptions : ( rootURI : URL ) => {
826+ const originalRootURI = rootURI . href
827+ rootURI . hash = ''
815828 return {
829+ originalRootURI,
816830 zipURL : constructZipURL ( {
817- repoName : pathname ( url . href ) . replace ( / ^ \/ + / , '' ) ,
818- revision : url . search . substr ( 1 ) ,
831+ repoName : pathname ( rootURI . href ) . replace ( / ^ \/ + / , '' ) ,
832+ revision : rootURI . search . substr ( 1 ) ,
819833 token,
820834 } ) ,
835+ zipURLTemplate : zipURLTemplate ( token ) ,
821836 }
822837 } ,
823838 } )
0 commit comments