Skip to content

Commit

Permalink
patch lc reconnection handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Moros1138 committed Jun 11, 2024
1 parent ebd6ad2 commit 91ff455
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions resources/js/components/EditorPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as vscode from "vscode";
export default class EditorPanel
{
state;
autoConnect = true;
autoConnect = true;
code = "";

monacoWrapper = null;
Expand Down Expand Up @@ -91,19 +91,32 @@ export default class EditorPanel
*
* sockets.... streaming dataaaaa aahh ahhh
*/
this.reconnectInterval = setInterval(async() =>
const reconnectHandler = async() =>
{
// we failed to connect the first time, let's not keep trying
if(!this.autoConnect)
return;

// language client is already started, let's not try, this time
if(this.monacoWrapper.getLanguageClientWrapper().isStarted())
{
return;
}

this.monacoWrapper.getLanguageClientWrapper().start();

}, 5000);
clearInterval(this.reconnectInterval);

try
{
await this.monacoWrapper.getLanguageClientWrapper().start();
}
catch(e)
{
// fail
}

this.reconnectInterval = setInterval(reconnectHandler, 5000);
}

if(this.autoConnect)
{
this.reconnectInterval = setInterval(reconnectHandler, 5000);
}

this.monacoWrapper.getEditor().setValue(code);

Expand Down

0 comments on commit 91ff455

Please sign in to comment.