Closed Bug 243532 Opened 20 years ago Closed 20 years ago

When move/copy of messages finishes, selection jumps

Categories

(SeaMonkey :: MailNews: Message Display, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: smjg, Assigned: lorenzo)

Details

(Keywords: fixed-aviary1.0)

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8a) Gecko/20040503
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8a) Gecko/20040503

I often file messages when reading newsgroups.  The copying operation happens in
the background, so I can continue reading more messages while it's doing it. 
However, it likes to tell me it's done copying by reselecting the first copied
message.  This means that I can easily lose my place in the thread I am reading.

The same thing happens whether I am copying from a newsgroup, or moving or
copying between local folders.

Reproducible: Always
Steps to Reproduce:
1. Select some messages.
2. Drag them into a folder.
3. While waiting for the messages to transfer, select another message.

Actual Results:  
If messages were copied, then the first message copied becomes selected once it
has finished.  If moved, the selection jumps to the message immediately below
where it has moved from.

Expected Results:  
Left the selection where I put it.  If the selection as at the end of a move
operation consists only of messages that have been moved, then and only then
should it select the next message.
This also happens with IMAP messages, and on all platforms.
OS: MacOS X → All
Hardware: Macintosh → All
Attached patch patch v1Splinter Review
This patch makes it so that gNextMessageViewIndexAfterDelete is set to -2 when
a message is displayed in the message pane, so when the move or delete
operation completes the selection does not "snap back" to the message chosen by
SetNextMessageAfterDelete() when the operation started.
Assignee: sspitzer → lorenzo
Status: NEW → ASSIGNED
Comment on attachment 152276 [details] [diff] [review]
patch v1

Neil, can you look at this?
Attachment #152276 - Flags: review?(neil.parkwaycc.co.uk)
It's true that there are other ways to change the selection than displaying a
message, but I think this is the most important case because the user is
probably trying to read the message he just selected and doesn't want to be
interrupted.
CC'ing Scott on this usability issue
The perfect fix would be to set gNextMessageViewIndexAfterDelete to -2 whenever
the tree selection changes. But I can't figure out a way to do that.
Attachment #152276 - Flags: review?(neil.parkwaycc.co.uk)
Cancelling review request based on Neil's comments over IRC.

Neil suggests using ThreadPaneSelectionChanged in threadPane.js to check if the
selection has changed. This is needed for 3-pane with a collapsed message pane,
and for the search pane, which don't load messages. But the original fix needs
to be implemented for the standalone message window.

I will post an updated patch soon.
Hmm, it turns out it's not as simple as that. ThreadPaneSelectionChanged can be
called for other reasons than the user changing the selection himself. For
example, it's called by gDBView.onDeleteCompleted in
HandleDeleteOrMoveMsgCompleted when a message is deleted and from elsewhere in
C++ code when a message is moved. We could add hacks to both these places, but
I'm not sure that would be a good idea.
When I tried moving a message the select handler got called via
HandleDeleteOrMoveMsgCompleted's call to onDeleteCompleted.
When I move a message from one IMAP to another, I see this stack before the one
containing onDeleteCompleted:

#0  nsTreeSelection::FireOnSelectHandler()
#1  in nsTreeSelection::AdjustSelection(int, int)
#2  in nsTreeBodyFrame::RowCountChanged(int, int)
#3  in nsTreeBoxObject::RowCountChanged(int, int)
#4  in nsMsgDBView::NoteChange(unsigned, int, int)
#5  in nsMsgDBView::RemoveByIndex(unsigned)
#7  in nsMsgDBView::OnKeyDeleted(unsigned, unsigned, int, nsIDBChangeListener*)
#8  in nsMsgDatabase::NotifyKeyDeletedAll(unsigned, unsigned, int,
nsIDBChangeListener*)
#9  in nsMsgDatabase::DeleteHeader(nsIMsgDBHdr*, nsIDBChangeListener*, int, int)
#10 in nsMsgDatabase::DeleteMessages(nsMsgKeyArray*, nsIDBChangeListener*)
#12 in nsImapMailFolder::OnStopRunningUrl(nsIURI*, unsigned)

so it doesn't look like it's possible to find out whether the user changed the
selection himself or something else did it.

I think we should go for the 90% fix in attachment 152276 [details] [diff] [review], or something like it.
I'll do some more testing and see how it goes.
http://lxr.mozilla.org/seamonkey/source/mailnews/base/src/nsMsgDBView.cpp#2509
RemoveByIndex shouldn't call NoteChange in the middle of a move or delete...
>RemoveByIndex shouldn't call NoteChange in the middle of a move or delete

the m_deletingRows var is used to determine if the user deleted the messages by
pressing delete - was this move done by drag+drop? Or the File menu? Perhaps we
just need to set that var (as much as I hate that whole m_deletingRows stuff) in
those cases...assuming we still get the OnDeleteCompleted notification.

Re the news issue, you're really doing a copy, because delete isn't supported
for newsgroups - that sounds like a potentially separate issue.
(In reply to comment #12)
> >RemoveByIndex shouldn't call NoteChange in the middle of a move or delete
> the m_deletingRows var is used to determine if the user deleted the messages
> by pressing delete - was this move done by drag+drop? Or the File menu?

Yes, this was done by dragging the message with the mouse.

> Perhaps we just need to set that var (as much as I hate that whole 
> m_deletingRows stuff) in those cases...assuming we still get the
> OnDeleteCompleted notification.

Hmm, set which var in what cases? I'm not sure I get your point.

> Re the news issue, you're really doing a copy, because delete isn't supported
> for newsgroups - that sounds like a potentially separate issue.

I see. Maybe something similar would work there too...
Yes, I see that trace via drag&drop, but we should improve drag&drop rather than
not fixing this just because drag&drop doesn't do things correctly...
How the user initiated the move/copy/delete operation seems immaterial to me. 
Am I missing something?
Yes, we need to distinguish between deletes initiated in the current window and
deletes initiated in another window, or in the case of IMAP, another client.
This is the same patch as before except for branch (thunderbird only).

It's a 90% fix that takes care of the common (and most annoying) case where a
user deletes or moves one or more messages by dragging them with the mouse and
then starts reading another message.
Comment on attachment 156130 [details] [diff] [review]
same patch for branch thunderbird

Requesting review.

Scott, shall we go for this 90% fix for now? I don't think I will be able to
come up with something better in the near future.
Attachment #156130 - Flags: review?(mscott)
Note that this also fixes the Local Folders case originally reported, but I am
unable to reproduce the newsgroup case with a current build of thunderbird.
Comment on attachment 156130 [details] [diff] [review]
same patch for branch thunderbird

I've been running with this for quite a while now with no strange behaviour.
Scott, could you look at it and check it in if you like it?
Attachment #156130 - Flags: review?(mscott) → superreview?(mscott)
Comment on attachment 156130 [details] [diff] [review]
same patch for branch thunderbird

Oops, really requesting review
Attachment #156130 - Flags: review?(mscott)
Comment on attachment 156130 [details] [diff] [review]
same patch for branch thunderbird

I'm ok with this 90% fix for Thunderbird for now as it does make things much
better in the short term.

It sounds like Neil may have some questions for fixing this all the way if I
read the bug right. I'll defer to him on what	to do for seamonkey.
Attachment #156130 - Flags: superreview?(mscott)
Attachment #156130 - Flags: superreview?(bienvenu)
Attachment #156130 - Flags: review?(mscott)
Attachment #156130 - Flags: review+
Comment on attachment 156130 [details] [diff] [review]
same patch for branch thunderbird

sr=bienvenu - however, do you really need to check that
gNextMessageViewIndexAfterDelete is >= 0? Can you just always set it to -2 here
and save a little bit of code?
Attachment #156130 - Flags: superreview?(bienvenu) → superreview+
Lorenzo - I'm a bit puzzled.  You took out the review request on attachment
152276 [details] [diff] [review], and then requested a review on attachment 156130 [details] [diff] [review], even though they're
exactly the same apart from the position in the CVS tree.

So, are we still going to have the fix for plain Mozilla?
Same as the previous patch for branch Thunderbird, but with Bienvenu's
suggestion. I've been running with this for a while and it seems to work fine.
Attachment #156130 - Attachment is obsolete: true
Comment on attachment 161775 [details] [diff] [review]
patch with Bienvenu's suggestion

Carrying forward review requests.

Scott, David, could one of you check this in? Thanks!
Attachment #161775 - Flags: superreview+
Attachment #161775 - Flags: review+
you need this checked into the trunk for seamonkey and thunderbird, and for the
aviary branch for thunderbird? I can do that...
fixed trunk, tbird and seamonkey, branch tbird. Thanks, Lorenzo.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Keywords: fixed-aviary1.0
Resolution: --- → FIXED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: