diff --git a/src/client.ts b/src/client.ts index 8591d9a..88533a0 100644 --- a/src/client.ts +++ b/src/client.ts @@ -176,6 +176,13 @@ async function send( Public API ────────────────────────── */ +export async function closeClient() { + if (!socket) return; + socket.close(); + socket = null; + connecting = null; +} + export async function addRun( useLocalhost: boolean, problem: string, diff --git a/src/extension.ts b/src/extension.ts index 385b938..4a1e5c2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,6 +4,7 @@ import { startServer, stopServer } from "./server"; import os from "os"; import { exec } from "child_process"; import net from "net"; +import { closeClient } from "./client"; var globalStatusBarItem: vscode.StatusBarItem | undefined; @@ -105,6 +106,7 @@ export function activate(context: vscode.ExtensionContext) { export function deactivate() { stopServer(globalStatusBarItem as any); + closeClient(); } export function canConnect( diff --git a/src/move.ts b/src/move.ts index 8b9a1a9..12db055 100644 --- a/src/move.ts +++ b/src/move.ts @@ -129,7 +129,7 @@ export function startMonitoring(useLocalhost: boolean, runId: string) { moveId: moveId++, changes: { from: 0, - to: serverText.length, + to: serverText?.length || 0, insert: editorText, }, },