different instances of selection in selectionService.onSelectionChanged
December 16, 2019 at 2:29pmdifferent instances of selection in selectionService.onSelectionChanged
December 16, 2019 at 2:29pmHi,
I'm using selectionService.onSelectionChanged to catch selection events from file explorer and from editor tabs.
I noticed that the selection parameter (this.selectionService.selection) in the event handler is different when it's fired from the file explorer or from editor's tabs.
When changing the selection from the file explorer i get an array of the selections.
When changing the selection from the editor tabs i get an object of monaco editor with the uri of the selection inside.
Is that inconsistency ok?
December 16, 2019 at 3:03pm
It is expected, different active widgets can have own definition of what is a selection. What are you trying to achieve?
There are helper classes which allow to get different shapes of a selection from
SelectionService
.For example
UriSelection.getUri
, for commands you can simply use UriAwareCommandHandler
or WorkspaceRootUriAwareCommandHandler
.for trees there is
TreeWidgetSelection
You can also use
SelectionCommandHandler
to support commands based on your own definition of a selection, see for example FileSelection.CommandHandler
December 26, 2019 at 11:11am