Creating selection, markers and removing it


#1

Hey all,
I’m working on my @devunity package, as im adding a feature which lets you see who exactly is selecting text via coloring im stuck with an issue.
When ever someone highlights a line remotely it is broadcasted properly into atom, the color selection is decorated according to the remote user color. But, when the remote user deselects the selection remains and also multiple cursors are added…

the function im using right now is this:

  cursorRange.id = this.atom.markBufferRange(cursorRange);
    cursorRange.cursor = cursor;
    cursorRange.decoration = this.atom.decorateMarker(cursorRange.id, {type:'line',class:clazz});
    //cursorRange.selection = this.atom.setSelectedBufferRange(cursorRange.id.getBufferRange());
    cursorRange.selection = this.atom.addSelectionForBufferRange(cursorRange.id.getBufferRange());

im sorry, im just adding for future refer : solved it!

  cursorRange.selection.cursor.destroy();
      cursorRange.decoration.destroy();
      cursorRange.selection.marker.destroy();
      cursorRange.selection.clear();

will void the selection and cursors. is this the best practice todo so?


#2

tried doing this:

  editor = atom.workspace.getActiveEditor()
      curs = editor.getCursors();
      for (i=0;curs.length > 0;i++) {
        curs[i].destroy()
      }

at no luck. throws error that it cant find cursors screen position.