Bug 153105 - [Viewers] Mac: Copying contents of any tree view, such as callstack, variables, or outline, copies lines to clipboard in reverse order
Summary: [Viewers] Mac: Copying contents of any tree view, such as callstack, variable...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.3 M2   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 153700 (view as bug list)
Depends on: 18377
Blocks:
  Show dependency tree
 
Reported: 2006-08-08 12:10 EDT by Mac Martine CLA
Modified: 2006-09-16 10:02 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mac Martine CLA 2006-08-08 12:10:09 EDT
Reproduction:
1. Mac only: Select multiple lines in any of the Eclipse views which is a tree control: e.g. Outline, Debug, Variables, Breakpoints
2. Command-C to copy to clipboard
3. Run TextEdit
4. Paste

Actual Results:
The lines are pasted in the reverse order from the order in which they appeared in the original location.

Expected Results:
Should be in the same order.

I tried Eclipse 3.2 on Windows; this did not reproduce there. So the bug is specific to the Mac version of Eclipse.
Comment 1 Paul Webster CLA 2006-08-09 07:35:52 EDT
Have you tried 3.2 on Mac?  This bug says the problem is in version 3.1.1.

PW
Comment 2 Mac Martine CLA 2006-08-09 10:37:39 EDT
It occurs in 3.1 and 3.2. I changed this to say 3.2. Thanks!
Comment 3 Boris Bokowski CLA 2006-08-09 11:08:18 EDT
The root cause of this is that SWT's Tree.getSelection() explicitly says that the order of the returned items is unspecified.  In practice, for Linux/GTK and Windows, the returned items are in order, and on the Mac, the order is reversed.

Steve, any chance the API for getSelection() can be strengthened so that the items are returned in order?  If not, all clients (or JFace) would have to sort the result of getSelection() themselves.
Comment 4 Mike Morearty CLA 2006-08-09 13:05:59 EDT
Regarding comment #3, "If not, all clients (or JFace) would have to sort the result of getSelection() themselves": I might be missing something because I'm not too familiar with this code, but I don't see how having the client sort the result would even be possible.  E.g. let's say you are debugging, and you copy the callstack to the clipboard.  If the "copy" code sorted the array of TreeItems, would it be an alphanumeric sort?  If so, then that would reshuffle all the callstack entries into essentially random order.  That would be an amusing effect :-)
Comment 5 Boris Bokowski CLA 2006-08-09 13:16:33 EDT
(In reply to comment #4)
> If the "copy" code sorted the array of
> TreeItems, would it be an alphanumeric sort?  If so, then that would reshuffle
> all the callstack entries into essentially random order.  That would be an
> amusing effect :-)

This is not what I meant.  Sorting is easy in cases where we already use a sorter (e.g., in the resource navigator where resources are sorted alphabetically).  If we are just displaying a list of items in their natural order, sorting would have to recreate that natural order.

I don't know what the behaviour on each of the platforms is so we need an answer from SWT.  Theoretically, one could imagine a platform that returns the items in the order they were selected, but I don't know if such a platform exists.
Comment 6 Steve Northover CLA 2006-08-10 01:04:29 EDT
Sorry Boris, this has come in before.  We don't have control of the order in which the items in the selection are returned.  On Windows, the order can vary as well (try deleting and adding items).
Comment 7 Paul Webster CLA 2006-08-14 09:02:11 EDT
*** Bug 153700 has been marked as a duplicate of this bug. ***
Comment 8 Boris Bokowski CLA 2006-08-14 16:51:44 EDT
(In reply to comment #6)
> Sorry Boris, this has come in before.  We don't have control of the order in
> which the items in the selection are returned.  On Windows, the order can vary
> as well (try deleting and adding items).

Is there anything SWT can do to help us sort the tree items, or would we have to do that ourselves?
Comment 9 Steve Northover CLA 2006-08-14 17:42:00 EDT
Sorry, you'll need to do it yourself.  The order is not guaranteed in the operating system.
Comment 10 Boris Bokowski CLA 2006-09-16 10:02:32 EDT
Fixed in SWT.