chore: refactor

This commit is contained in:
frelodev 2024-10-05 18:21:20 +02:00
parent af3cde19fc
commit 2a72104a02
3 changed files with 10 additions and 10 deletions

View file

@ -36,7 +36,7 @@ export async function apply_changes_to_buffer(path: string, controller: codemp.B
.replace(range, event.content) .replace(range, event.content)
})) { })) {
vscode.window.showWarningMessage("Couldn't apply changes"); vscode.window.showWarningMessage("Couldn't apply changes");
await resync(path, workspace, editor, 100); await resync(path, workspace, editor, 100);
} }
locks.delete(path); locks.delete(path);
@ -244,7 +244,7 @@ export async function resync(buffer_name: string, workspace: codemp.Workspace, e
console.log("attempts to sync", i); console.log("attempts to sync", i);
break; break;
} }
if (i == tries-1) { if (i == tries - 1) {
vscode.window.showErrorMessage(`Failed setting buffer content after ${tries} tries`); vscode.window.showErrorMessage(`Failed setting buffer content after ${tries} tries`);
} }
} }

View file

@ -8,7 +8,7 @@ import { LOGGER, provider } from '../extension';
// TODO this "global state" should probably live elsewher but we need lo update it from these commands // TODO this "global state" should probably live elsewher but we need lo update it from these commands
export let client: codemp.Client | null = null; export let client: codemp.Client | null = null;
export let workspace_list: string[] = []; export let workspace_list: string[] = [];
export let cursor_disposable : vscode.Disposable | null; export let cursor_disposable: vscode.Disposable | null;
export async function connect() { export async function connect() {
let config = vscode.workspace.getConfiguration('codemp'); let config = vscode.workspace.getConfiguration('codemp');
@ -59,7 +59,7 @@ export async function join(selected: vscode.TreeItem | undefined) {
setWorkspace(await client.join_workspace(workspace_id)); setWorkspace(await client.join_workspace(workspace_id));
if (!workspace) return; if (!workspace) return;
let controller = workspace.cursor(); let controller = workspace.cursor();
controller.callback(async function(controller: codemp.CursorController) { controller.callback(async function (controller: codemp.CursorController) {
while (true) { while (true) {
let event = await controller.try_recv(); let event = await controller.try_recv();
if (workspace === null) { if (workspace === null) {
@ -104,12 +104,12 @@ export async function join(selected: vscode.TreeItem | undefined) {
once = false; once = false;
} else { } else {
await controller.send({ await controller.send({
startRow: selection.anchor.line, startRow: selection.anchor.line,
startCol: selection.anchor.character, startCol: selection.anchor.character,
endRow: selection.active.line, endRow: selection.active.line,
endCol: selection.active.character, endCol: selection.active.character,
buffer: buffer, buffer: buffer,
user: undefined, user: undefined,
}); });
once = true; once = true;
} }

View file

@ -3,7 +3,7 @@ import * as codemp from 'codemp';
import { client, connect, join, refresh, createWorkspace, inviteToWorkspace, listWorkspaces, leave } from './commands/client'; import { client, connect, join, refresh, createWorkspace, inviteToWorkspace, listWorkspaces, leave } from './commands/client';
import { CodempTreeProvider } from './tree'; import { CodempTreeProvider } from './tree';
import * as mapping from './mapping'; import * as mapping from './mapping';
import { workspace, jump, listBuffers, createBuffer , deleteBuffer } from './commands/workspaces' import { workspace, jump, listBuffers, createBuffer, deleteBuffer } from './commands/workspaces'
import { attach, share, sync, apply_changes_to_buffer, detach } from './commands/buffers' import { attach, share, sync, apply_changes_to_buffer, detach } from './commands/buffers'
export let provider = new CodempTreeProvider(); export let provider = new CodempTreeProvider();