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

Commit feb0a79

Browse files
committed
.
1 parent e196093 commit feb0a79

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
@@ -703,7 +703,7 @@ const DUMMY_CTX = { subscriptions: { add: (_unsubscribable: any) => void 0 } }
703703

704704
export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
705705
async function afterActivate(): Promise<void> {
706-
if (Math.random() < 0) {
706+
if (!sourcegraph.configuration.get().get('lspclient')) {
707707
const address = sourcegraph.configuration.get<Settings>().get('go.serverUrl')
708708
if (address) {
709709
await activateUsingWebSockets(ctx)
@@ -761,16 +761,31 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
761761
},
762762
}),
763763
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 (/^file:\/\/\//.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 = ''
768781
return {
782+
originalRootURI,
769783
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),
772786
token,
773787
}),
788+
zipURLTemplate: zipURLTemplate(token),
774789
}
775790
},
776791
})

0 commit comments

Comments
 (0)