From 707c89cf31234845fff010de598cbe9daccbe3b0 Mon Sep 17 00:00:00 2001 From: cschen Date: Mon, 5 Aug 2024 22:46:01 +0200 Subject: [PATCH] fix: bad hack to move around the single user login in the workspace Former-commit-id: 2e9f8938636593a5b7c7fedd173fc9ae81aa795e --- Cargo.toml | 4 ++-- plugin.py | 2 +- src/client.py | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 943d9d3..4f00020 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,8 @@ name = "codemp" crate-type = ["cdylib"] [dependencies] -codemp = { git = "ssh://git@github.com/codewithotherpeopleandchangenamelater/codemp.git", tag="v0.6.1"} -codemp-proto = { git = "ssh://git@github.com/codewithotherpeopleandchangenamelater/codemp-proto.git", tag = "v0.6.1" } +codemp = { git = "ssh://git@github.com/hexedtech/codemp.git", branch="glue"} +codemp-proto = { git = "ssh://git@github.com/hexedtech/codemp-proto.git", tag = "v0.6.1" } pyo3 = { version = "0.20", features = ["extension-module"] } pyo3-asyncio = { version = "0.20", features = ["tokio-runtime"] } serde = { version = "1.0.196", features = ["derive"] } diff --git a/plugin.py b/plugin.py index b736c71..9af73e4 100644 --- a/plugin.py +++ b/plugin.py @@ -198,7 +198,7 @@ class CodempJoinCommand(sublime_plugin.WindowCommand): ############################################################################# class CodempJoinWorkspaceCommand(sublime_plugin.WindowCommand): def run(self, workspace_id): - tm.dispatch(client.join_workspace(workspace_id, "sublime3")) + tm.dispatch(client.join_workspace(workspace_id)) def input_description(self): return "Join specific workspace" diff --git a/src/client.py b/src/client.py index 48ea0b0..d4d3bee 100644 --- a/src/client.py +++ b/src/client.py @@ -2,6 +2,7 @@ from __future__ import annotations from typing import Optional import sublime +import random import asyncio import tempfile import os @@ -125,7 +126,7 @@ class VirtualBuffer: region.begin(), region.end(), change.str ) ) - self.buffctl.send(region.begin(), region.end(), change.str) + self.buffctl.send(region.begin(), region.end()+len(change.str)-1, change.str) def send_cursor(self, vws: VirtualWorkspace): # TODO: only the last placed cursor/selection. @@ -340,10 +341,10 @@ class VirtualClient: status_log(f"Connected to '{server_host}' with user id: {id}") async def join_workspace( - self, workspace_id: str, user="sublime2", password="lmaodefaultpassword" + self, workspace_id: str, user=f"user-{random.random()}", password="lmaodefaultpassword" ) -> Optional[VirtualWorkspace]: try: - status_log(f"Logging into workspace: '{workspace_id}'") + status_log(f"Logging into workspace: '{workspace_id}' with user: {user}") await self.handle.login(user, password, workspace_id) except Exception as e: status_log(