@@ -703,7 +703,7 @@ const DUMMY_CTX = { subscriptions: { add: (_unsubscribable: any) => void 0 } }
703
703
704
704
export function activate ( ctx : sourcegraph . ExtensionContext = DUMMY_CTX ) : void {
705
705
async function afterActivate ( ) : Promise < void > {
706
- if ( Math . random ( ) < 0 ) {
706
+ if ( ! sourcegraph . configuration . get ( ) . get ( 'lspclient' ) ) {
707
707
const address = sourcegraph . configuration . get < Settings > ( ) . get ( 'go.serverUrl' )
708
708
if ( address ) {
709
709
await activateUsingWebSockets ( ctx )
@@ -761,16 +761,31 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
761
761
} ,
762
762
} ) ,
763
763
documentSelector : [ { language : 'go' } ] ,
764
- // clientToServerURI: uri => ..., // optional
765
- // serverToClientURI: uri => ..., // optional
766
- initializationOptions : ( url : URL ) => {
767
- url . hash = ''
764
+ clientToServerURI : ( uri : URL ) => new URL ( `file:///${ uri . hash . slice ( 1 ) } ` ) ,
765
+ serverToClientURI : ( uri , currentRootURI ) => {
766
+ if ( ! currentRootURI ) {
767
+ return uri
768
+ }
769
+
770
+ if ( / ^ f i l e : \/ \/ \/ / . test ( uri . href ) ) {
771
+ // The definition is in a file in the same repo
772
+ const docURL = new URL ( currentRootURI . href )
773
+ docURL . hash = uri . href . slice ( 'file:///' . length )
774
+ return docURL
775
+ }
776
+ return uri
777
+ } ,
778
+ additionalInitializationOptions : ( rootURI : URL ) => {
779
+ const originalRootURI = rootURI . href
780
+ rootURI . hash = ''
768
781
return {
782
+ originalRootURI,
769
783
zipURL : constructZipURL ( {
770
- repoName : pathname ( url . href ) . replace ( / ^ \/ + / , '' ) ,
771
- revision : url . search . substr ( 1 ) ,
784
+ repoName : pathname ( rootURI . href ) . replace ( / ^ \/ + / , '' ) ,
785
+ revision : rootURI . search . substr ( 1 ) ,
772
786
token,
773
787
} ) ,
788
+ zipURLTemplate : zipURLTemplate ( token ) ,
774
789
}
775
790
} ,
776
791
} )
0 commit comments