Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 402377

Summary: Multiple item selection in the navigator no longer sends out selection changed event.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: ClientAssignee: Susan McCourt <susan>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: susan
Version: 2.0   
Target Milestone: 3.0 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description libing wang CLA 2013-03-04 15:23:49 EST
Found this when I tried to implement the compact size compare widget.
When I selected two files, the "compare with each other" action is gone.
Similarly, if you choose two folders, the git status action shows up. This should show up only when a single selection is on.

Debugged a little bit, the root cause is that selection.js is checking "oldSelection !== newSelection" to send out "selectionChanged" event. But the old selection is already updated by the explorerNavHandler before selection.setSelection is called.
Comment 1 Susan McCourt CLA 2013-03-04 22:34:11 EST
the problem is that the explorer nav code is querying the selection service array, modifying it, and then calling API to reset it.  Since it's already set the array itself, the service doesn't see a change.

We need to decide on the contract on the array data.  Should we make a copy when queried for selection?  And when set?

Note that the behavior would differ depending on whether you were going through the service registry or not (because the parameters would go through json).

So we need to spec on the selection side what the rules are.
Comment 2 Susan McCourt CLA 2013-03-06 11:56:51 EST
Fixed in
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=5b4477e2b7646ef6d7c5060ffad1c2bc1ea14a44

Any solution where the spec says "don't modify this array" seems wrong.
And any solution where the client says "send the changed event even if you don't see a change" defeats the purpose of the fix in bug 382428 because the navigator code would again be firing a bunch of unnecessary change events.

The safest thing is to copy the array as it comes in and out by API, and this means that parameters passing through the service registry will be handled the same as those that don't.