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

Bug 419170

Summary: selection anchor item must be cleared when ancestor of focused item is collapsed
Product: [ECD] Orion Reporter: Grant Gayed <grant_gayed>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: grant_gayed
Version: 4.0Flags: grant_gayed: review+
Target Milestone: 4.0 RC2   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch
none
second patch none

Description Grant Gayed CLA 2013-10-10 13:37:33 EDT
I20131010-0722

Test case:

item a
item b
item c
  +-----item c1 (child of item c)
item d
item e
item f

- give focus to item c1
- collapse item c
- press down-arrow
    -> focus appears on item b, indicating that the collapsing of item c gave focus to item a (though its focus rect was not drawn)
- re-expand item c
- give focus to item c1
- collapse item c
- shift+click on item f
    -> selection becomes d-f, because it's still using item c1 (which is conceptually between items c and d) as the anchor
    -> if item a is really the focus item at this point then it should be the anchor
Comment 1 libing wang CLA 2013-10-10 13:44:24 EDT
Good catch.
There is code handling the similar case for current selected item, I think I just forgot to sync the shiftAnchor.
Comment 2 libing wang CLA 2013-10-11 11:50:32 EDT
Created attachment 236379 [details]
Patch
Comment 3 Grant Gayed CLA 2013-10-11 12:50:54 EDT
The following case still shows the problem:

- select item b
- Ctrl+Select item c1
- collapse item c
- Shift+Select item f
    -> selects items d-f, presumably because the selection count did not reach 0 when item c1 was collapsed
Comment 4 libing wang CLA 2013-10-11 14:17:53 EDT
Created attachment 236412 [details]
second patch
Comment 5 libing wang CLA 2013-10-11 14:23:11 EDT
(In reply to Grant Gayed from comment #3)
> The following case still shows the problem:
> 
> - select item b
> - Ctrl+Select item c1
> - collapse item c
> - Shift+Select item f
>     -> selects items d-f, presumably because the selection count did not
> reach 0 when item c1 was collapsed

Yeah, the issue is that there are remaining selections that are not collapsed.
So I changed the logic as this:
If there is an anchor and the anchor is in the refreshed selection list, then we just keep it. Otherwise just clear it.
This logic is also good for thsi flow:
1.Click on a
2.Shift click on d.
3.Collapse c.
4.Shift click on f

At step 3 in the rowChanged event handling, it does not change the shift anchor because the anchor is in the refreshed selection list.
Comment 6 Grant Gayed CLA 2013-10-11 14:50:52 EDT
re-reviewed, seems fine
Comment 7 libing wang CLA 2013-10-11 15:01:48 EDT
Thanks for the review and the test cases, Grant.
Pushed the fix with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=ef4cf7f350a46679ac72a59699647471a935d541.