Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Commit dfe2969

Browse files
committed
.
1 parent 94d914d commit dfe2969

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/lang-go.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ const DUMMY_CTX = { subscriptions: { add: (_unsubscribable: any) => void 0 } }
741741

742742
export 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 (/^file:\/\/\//.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

Comments
 (0)