feat: detach

Co-authored-by: alemi <me@alemi.dev>
This commit is contained in:
frelodev 2024-10-02 23:42:09 +02:00
parent 87f2b6f2fb
commit 9c00cf9eeb
3 changed files with 10 additions and 2 deletions

View file

@ -156,6 +156,12 @@
"category": "codemp",
"icon": "$(output-view-icon)"
},
{
"command": "codemp.detach",
"title": "Detach from Buffer",
"category": "codemp",
"icon": "$(arrow-down)"
},
{
"command": "codemp.sync",
"title": "Sync",

View file

@ -173,7 +173,7 @@ export async function detach(selected: vscode.TreeItem | undefined) {
buffer_name = selected.label.label; // TODO ughh what is this api?
}
} else {
buffer_name = await vscode.window.showInputBox({ prompt: "path of buffer to attach to" });
buffer_name = await vscode.window.showInputBox({ prompt: "path of buffer to detach from" });
}
if (!buffer_name) return;
let controller = workspace.buffer_by_name(buffer_name);
@ -181,6 +181,7 @@ export async function detach(selected: vscode.TreeItem | undefined) {
workspace.detach(buffer_name);
mapping.bufferMapper.remove(buffer_name);
vscode.window.showInformationMessage(`Detached from buffer ${buffer_name}`)
provider.refresh();
}

View file

@ -4,7 +4,7 @@ import { client, connect, join, refresh, createWorkspace, inviteToWorkspace, lis
import { CodempTreeProvider } from './tree';
import * as mapping from './mapping';
import { workspace, jump, listBuffers, createBuffer } from './commands/workspaces'
import { attach, share, sync, apply_changes_to_buffer } from './commands/buffers'
import { attach, share, sync, apply_changes_to_buffer, detach } from './commands/buffers'
export let provider = new CodempTreeProvider();
@ -41,6 +41,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('codemp.leaveWorkspace', leaveWorkspace),
vscode.commands.registerCommand('codemp.createBuffer', createBuffer),
vscode.commands.registerCommand('codemp.listBuffers', listBuffers),
vscode.commands.registerCommand('codemp.detach', detach),
vscode.commands.registerCommand('codemp.sync', sync),
vscode.commands.registerCommand('codemp.refresh', refresh),
vscode.commands.registerCommand('codemp.jump', jump),