Skip to content

Commit

Permalink
fix(frontend): reload websocket on lsp go import install
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Nov 6, 2022
1 parent 83c79a4 commit 5b4c9d9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions frontend/src/lib/components/Editor.svelte
Expand Up @@ -221,6 +221,19 @@
const languageClient = createLanguageClient({ reader, writer }, name, options)
websockets.push([languageClient, webSocket])
// HACK ALERT: for some reasons, the client need to be restarted to take into account the 'go get <dep>' command
// the only way I could figure out to listen for this event is this. I'm sure there is a better way to do this
if (name == 'go') {
const om = webSocket.onmessage
webSocket.onmessage = (e) => {
om && om.apply(webSocket, [e])
const js = JSON.parse(e.data)
if (js.method == 'window/showMessage' && js.params.message == 'completed') {
console.log('reloading websocket after go get')
reloadWebsocket()
}
}
}
reader.onClose(async () => {
try {
console.log('CLOSE')
Expand Down

0 comments on commit 5b4c9d9

Please sign in to comment.