mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-22 07:24:49 +01:00
feat: jump to other user's cursor
This commit is contained in:
parent
2d9dca2b0a
commit
01a91d79ec
3 changed files with 37 additions and 1 deletions
11
package.json
11
package.json
|
@ -86,6 +86,11 @@
|
|||
"command": "codemp.sync",
|
||||
"when": "view == codemp-tree-view && viewItem == buffer_active",
|
||||
"group": "inline"
|
||||
},
|
||||
{
|
||||
"command": "codemp.jump",
|
||||
"when": "view == codemp-tree-view && viewItem == user",
|
||||
"group": "inline"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -168,6 +173,12 @@
|
|||
"title": "Refresh",
|
||||
"category": "codemp",
|
||||
"icon": "$(extensions-refresh)"
|
||||
},
|
||||
{
|
||||
"command": "codemp.jump",
|
||||
"title": "Jump",
|
||||
"category": "codemp",
|
||||
"icon": "$(debug-step-into)"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
|
|
|
@ -418,6 +418,31 @@ export async function refresh() {
|
|||
provider.refresh();
|
||||
}
|
||||
|
||||
export async function jump(selected: vscode.TreeItem | undefined){
|
||||
if (client === null) throw "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 = user.split(' (')[0];//Label on tree also contains Buffer name along with username
|
||||
else user = await vscode.window.showInputBox({ prompt: "username"});
|
||||
if (!user) return; // user cancelled with ESC
|
||||
|
||||
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);
|
||||
if (uri === undefined) {
|
||||
return vscode.window.showWarningMessage("user is on an untracked buffer: "+ user_hl.buffer);}
|
||||
let editor = await vscode.window.showTextDocument(uri, { preserveFocus: false });
|
||||
let range_start: vscode.Position = new vscode.Position(user_hl.startRow, user_hl.startCol);
|
||||
let range_end: vscode.Position = new vscode.Position(user_hl.endRow, user_hl.endCol);
|
||||
let cursor_range = new vscode.Range(range_start, range_end);
|
||||
editor.revealRange(cursor_range, vscode.TextEditorRevealType.InCenter);
|
||||
}
|
||||
|
||||
// This method is called when your extension is deactivated
|
||||
export function deactivate() {
|
||||
|
|
|
@ -47,7 +47,7 @@ export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeIte
|
|||
});*/
|
||||
for (let x of colors_cache){
|
||||
|
||||
out.push(new CodempTreeItem(`${x[0]}(${x[1].buffer})`, Type.User, false));
|
||||
out.push(new CodempTreeItem(`${x[0]} (${x[1].buffer})`, Type.User, false));
|
||||
};
|
||||
return out;
|
||||
case Type.Buffer:
|
||||
|
|
Loading…
Reference in a new issue