From 443cf308d73e5b1b31c59fdcce7545d439e0c477 Mon Sep 17 00:00:00 2001 From: JannisDommer Date: Tue, 12 Dec 2023 09:21:47 +0100 Subject: [PATCH] feat(connectionError): display connection error inside Editor --- WebSocketClient/package.json | 2 +- WebSocketClient/src/main.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/WebSocketClient/package.json b/WebSocketClient/package.json index 06e60b1..de17250 100644 --- a/WebSocketClient/package.json +++ b/WebSocketClient/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite dev && dark_mode_dev_env.sh", + "dev": "./dark_mode_dev_env.sh && vite dev", "build": "tsc && vite build", "preview": "vite preview" }, diff --git a/WebSocketClient/src/main.ts b/WebSocketClient/src/main.ts index 4e7bdad..fc2936d 100644 --- a/WebSocketClient/src/main.ts +++ b/WebSocketClient/src/main.ts @@ -62,7 +62,7 @@ const createWebSocket = (url: string): WebSocket => { const webSocket = new WebSocket(url); webSocket.onerror = () => { if(connectionText){ - connectionText.textContent = "Could not connect to language server. Reconnecting ..."; + displayEditorError( "Could not connect to language server. Reconnecting ..."); } setTimeout(() => { createWebSocket(url); @@ -70,7 +70,7 @@ const createWebSocket = (url: string): WebSocket => { }; webSocket.onopen = async () => { if(connectionText){ - connectionText.textContent = ""; + displayEditorError(""); } const socket = toSocket(webSocket); const reader = new WebSocketMessageReader(socket); @@ -308,6 +308,8 @@ export const startPythonClient = async () => { let globalEditor: IStandaloneCodeEditor | null; + +let currentWidget: IOverlayWidget | null; function displayEditorError(msg: string) { if(!globalEditor){ return; @@ -330,6 +332,10 @@ function displayEditorError(msg: string) { return node; } } + if(currentWidget){ + globalEditor.removeOverlayWidget(currentWidget); + } + currentWidget = overlayWidget; globalEditor.addOverlayWidget(overlayWidget); // setTimeout(() => { // if(!globalEditor) return;