0

I'm writing a Visual Studio Code extension that should be similar to Microsoft's Live Share extension. One of the features that I would like to replicate from their extension is add one more cursor in VSCode extension for my viewers, which are connected and edit my code in the session.

I want to add a similar implementation :

General Grievance
  • 4,555
  • 31
  • 31
  • 45

1 Answers1

0

set the editor.selections to a complete array of ranges:

editor.selections = [ new vscode.Selection(2,0,4,5), new vscode.Selection(5,2,6,0)]
rioV8
  • 24,506
  • 3
  • 32
  • 49
  • Yes, I did it, but how do I remove duplicate input from other cursors? And make only mine active? – Sergey Zaets Dec 28 '21 at 13:20
  • @SergeyZaets You completely overrule any selections prior to this statement, no duplicates – rioV8 Dec 28 '21 at 14:09
  • @rioV8I need to display other user's cursors and simultaneously can write from mine. At the same time, so that there is no duplicate. Could you send me a sample code? – Sergey Zaets Dec 28 '21 at 14:37
  • make a copy of the existing selections, add your selections, sort selections, determine overlap, remove overlap, set as new selection array – rioV8 Dec 28 '21 at 16:06