Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
danielzsh committed Feb 3, 2024
1 parent 1f39cb8 commit 3f786ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/editor/MonacoEditor/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function createLSPConnection() {
notify('Connecting to server...');
const url = createUrl('lsp.usaco.guide', 3000, '/sampleServer');
let webSocket: WebSocket | null = new WebSocket(url);
setInterval(() => {
const ping = setInterval(() => {
if (!webSocket) return;
webSocket.send(JSON.stringify({ jsonrpc: '2.0', method: 'ping' }));
}, 5000);
Expand All @@ -42,7 +42,6 @@ export default function createLSPConnection() {
console.error('Malformed message from LSP server:', event.data);
return;
}
console.log(message);
if (!webSocket) return;
if (message.method === 'start') {
const socket = toSocket(webSocket);
Expand Down Expand Up @@ -116,6 +115,7 @@ export default function createLSPConnection() {
return normalizeUrl(`${protocol}://${hostname}:${port}${path}`);
}
function dispose() {
clearInterval(ping);
if (!languageClient) {
// possibly didn't connect to websocket before exiting
if (webSocket && webSocket.readyState === webSocket.CONNECTING) {
Expand Down

0 comments on commit 3f786ab

Please sign in to comment.