mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-21 23:14:49 +01:00
feat: follow
This commit is contained in:
parent
2a72104a02
commit
dfe0650516
3 changed files with 36 additions and 2 deletions
12
package.json
12
package.json
|
@ -91,6 +91,11 @@
|
|||
"command": "codemp.jump",
|
||||
"when": "view == codemp-tree-view && viewItem == user",
|
||||
"group": "inline"
|
||||
},
|
||||
{
|
||||
"command": "codemp.follow",
|
||||
"when": "view == codemp-tree-view && viewItem == user",
|
||||
"group": "inline"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -187,6 +192,13 @@
|
|||
"category": "codemp",
|
||||
"icon": "$(debug-console-evaluation-input)"
|
||||
}
|
||||
,
|
||||
{
|
||||
"command": "codemp.follow",
|
||||
"title": "Follow User",
|
||||
"category": "codemp",
|
||||
"icon": "$(debug-console-evaluation-input)"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
"title": "codemp",
|
||||
|
|
|
@ -6,6 +6,7 @@ import { LOGGER, provider } from '../extension';
|
|||
|
||||
|
||||
export let workspace: codemp.Workspace | null = null;
|
||||
export let doFollow: boolean = false;
|
||||
|
||||
|
||||
export function setWorkspace(ws: codemp.Workspace | null) {
|
||||
|
@ -25,7 +26,10 @@ export async function jump(selected: vscode.TreeItem | undefined) {
|
|||
}
|
||||
if (!user) user = await vscode.window.showInputBox({ prompt: "username" });
|
||||
if (!user) return; // user cancelled with ESC
|
||||
executeJump(user);
|
||||
}
|
||||
|
||||
export async function executeJump(user: string) {
|
||||
let user_hl = mapping.colors_cache.get(user);
|
||||
if (user_hl === undefined) return vscode.window.showWarningMessage("unknown position of such user");
|
||||
let uri = mapping.bufferMapper.uri_by_buffer(user_hl.buffer);
|
||||
|
@ -39,6 +43,23 @@ export async function jump(selected: vscode.TreeItem | undefined) {
|
|||
editor.revealRange(cursor_range, vscode.TextEditorRevealType.InCenter);
|
||||
}
|
||||
|
||||
export async function follow(selected: vscode.TreeItem | undefined) {
|
||||
doFollow=!doFollow
|
||||
if (client === null) return vscode.window.showWarningMessage("Connect first");
|
||||
let user;
|
||||
if (selected !== undefined && selected.label !== undefined) {
|
||||
if (typeof (selected.label) === 'string') {
|
||||
user = selected.label;
|
||||
} else {
|
||||
user = selected.label.label;
|
||||
}
|
||||
}
|
||||
if (!user) user = await vscode.window.showInputBox({ prompt: "username" });
|
||||
if (!user) return; // user cancelled with ESC
|
||||
while(doFollow){
|
||||
executeJump(user);
|
||||
}
|
||||
}
|
||||
|
||||
export async function createBuffer() {
|
||||
let bufferName: any = (await vscode.window.showInputBox({ prompt: "path of the buffer to create" }));
|
||||
|
@ -62,5 +83,5 @@ export async function deleteBuffer() {
|
|||
await workspace.delete(bufferName);
|
||||
vscode.window.showInformationMessage(`Deleted buffer :${bufferName}`);
|
||||
listBuffers();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as codemp from 'codemp';
|
|||
import { client, connect, join, refresh, createWorkspace, inviteToWorkspace, listWorkspaces, leave } from './commands/client';
|
||||
import { CodempTreeProvider } from './tree';
|
||||
import * as mapping from './mapping';
|
||||
import { workspace, jump, listBuffers, createBuffer, deleteBuffer } from './commands/workspaces'
|
||||
import { workspace, jump, listBuffers, createBuffer, deleteBuffer, follow } from './commands/workspaces'
|
||||
import { attach, share, sync, apply_changes_to_buffer, detach } from './commands/buffers'
|
||||
|
||||
export let provider = new CodempTreeProvider();
|
||||
|
@ -46,6 +46,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
vscode.commands.registerCommand('codemp.sync', sync),
|
||||
vscode.commands.registerCommand('codemp.refresh', refresh),
|
||||
vscode.commands.registerCommand('codemp.jump', jump),
|
||||
vscode.commands.registerCommand('codemp.follow', follow),
|
||||
]) {
|
||||
context.subscriptions.push(cmd);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue