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

Bug 327432

Summary: [regression] copy a text file -> should be added to context
Product: z_Archived Reporter: Lars Vogel <Lars.Vogel>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: beyhan.veliev, Lars.Vogel, sam.davis, shawn.minto, steffen.pingel, wrobel
Version: unspecified   
Target Milestone: 3.7   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
interest levels
none
fix for resource events
none
mylyn/context/zip none

Description Lars Vogel CLA 2010-10-11 06:41:21 EDT
If I copy a text file while working on a active task I think this new file should be added to the context of the task.

Example: Create a few text files and add them to your task. Copy one of them via Ctrl+C and add them via Ctrl+V -> not in the task context.
Comment 1 Steffen Pingel CLA 2010-10-11 19:47:25 EDT
Lars, which release of Mylyn are you using? We recenctly made some changes to the resource monitoring and I am wondering if we are ignoring too many events now.
Comment 2 Lars Vogel CLA 2010-10-12 03:23:11 EDT
Steffen, I'm using the Mylyn included in Eclipse 3.6.2 Helios.
Comment 3 Steffen Pingel CLA 2010-10-15 14:21:06 EDT
Thanks. That's the release where the resource monitoring changed.
Comment 4 Steffen Pingel CLA 2010-10-26 04:11:48 EDT
I'll tentatively schedule this for 3.4.3 so we remember to investigate.
Comment 5 Steffen Pingel CLA 2011-01-29 22:13:40 EST
Sam, if you get a chance could you take a look at this?
Comment 6 Sam Davis CLA 2011-02-01 13:40:28 EST
Sure.
Comment 7 Mik Kersten CLA 2011-02-16 11:15:40 EST
Shawn: This used to work.  Could it be the change to our resource monitoring policy?
Comment 8 Shawn Minto CLA 2011-02-16 12:05:53 EST
Yes, this is most likely the cause of the problem but I have not had time to investigate it yet.
Comment 9 Steffen Pingel CLA 2011-02-16 16:51:37 EST
Sorry, the target milestone got lost when moving bugs between projects. I would like to get this fixed for 3.5.
Comment 10 Shawn Minto CLA 2011-02-21 14:58:46 EST
Hi Lars, I can't seem to reproduce this based on the steps that you provided.  The only time that I see items that are copied not being added to the context is when:

# activate a task
# go to the filesystem and find a file that has not been modified recently
# make a copy of this file
# refresh the folder in Eclipse

This "failure" is due to the policy that we have where only files that were modified while the current task is active are added to the context.  I need to investigate whether we can get the creation date of files as well so that we can improve the handling of this case.
Comment 11 Lars Vogel CLA 2011-02-21 15:35:43 EST
Hi Shawn,

I have this behavior every day, so it difficult to see why it works for you. 

For example:

1.) Create General project "mylyn"
2.) Create new local task and activite it
3.) Create new folder
4.) Create new file in Eclipse
5.) Cntl+C and Cntrl+v the file in Eclipse -> not added to active task
Best regards, Lars
Comment 12 Steffen Pingel CLA 2011-02-21 15:56:30 EST
If I follow the exact same steps it works for me. Lars, can you try starting with a fresh workspace to verify that you can reproduce it with the default settings?
Comment 13 Steffen Pingel CLA 2011-02-21 16:03:37 EST
To clarify, if Tasks > Resources > Enable file change monitoring is disabled in the preferences I can reproduce the problem described in comment#11 but that setting should be enabled by default. Also check if there are any exclusion rules that would disable resource monitoring on folder you are pasting into.
Comment 14 Lars Vogel CLA 2011-02-21 16:14:19 EST
Hi Steffen,

In my normal workspace I have Tasks > Resources > Enable file change monitoring enabled and no exclusions are defined.

If I create a new workspace it still shows the same behavior. The default creates a few exclusions **/.*/**, etc. But even if I delete them a newly copied file is not added to the context. 

Best regards, Lars
Comment 15 Steffen Pingel CLA 2011-03-07 18:17:59 EST
Shawn, what is the status of this bug?
Comment 16 Steffen Pingel CLA 2011-03-08 19:47:10 EST
I am moving this to the next milestone. We currently don't have a good handle how to investigate further. Lars, if you are at EclipseCon I suggest that we take a look at your workspace together.
Comment 17 Lars Vogel CLA 2011-03-12 16:17:37 EST
Thanks Steffen. Unfortunately I will not be able to join EclipseCon. Perhaps the next time we meet we find some time to look at this issue. :-)
Comment 18 Steffen Pingel CLA 2011-05-03 10:32:12 EDT
Steps to reproduce:
1. Activate a task
2. Copy an existing file that has a modification and creation date pre-dating the task activation
3. Paste the file

The file is not added to the context.
Comment 19 Shawn Minto CLA 2011-05-06 17:48:12 EDT
It turns out that I am able to reproduce this now!  I don't know why I couldn't when I tried before.  The problem is the date modification strategy is only able to take into account the modification date of the file (which does change when a file is copied).  Also, we are unable to detect if this change happened in Eclipse or from the workspace.  I wonder if we should just remove the use of this strategy for the case of added files and just allow the heuristic of the number of files being added control the context pollution.  I will have a deeper look into this as well and see if there isn't something else that we can do.
Comment 20 Steffen Pingel CLA 2011-05-13 05:24:37 EDT
*** Bug 345695 has been marked as a duplicate of this bug. ***
Comment 21 Sam Davis CLA 2011-06-30 17:22:37 EDT
I am noticing this too, when copying a file within Eclipse.
Comment 22 Steffen Pingel CLA 2011-09-07 18:45:34 EDT
Timed out. Deferring to next maintenance release.
Comment 23 Shawn Minto CLA 2012-03-15 12:37:31 EDT
I had another look into this and see no good solution here still.  The proposed fix in comment #19 is still the only valid one that I can think of as copying a file does not update the modification date and therefore it will not be modified when active.  Steffen, what do you think about disabling the modification date heuristic when it is a file addition?
Comment 24 Steffen Pingel CLA 2012-03-15 14:09:28 EDT
Let's do that. I don't see any simple way to detect user initiated file creation vs. tool initiated file creation and as long as we can control the volume of added files that seems like a good middle ground.
Comment 25 Lars Vogel CLA 2012-03-15 14:39:01 EDT
Great to see that this bug might be closed in the near future! Thanks.
Comment 26 Steffen Pingel CLA 2012-03-15 19:55:19 EDT
Shawn, have you considered hooking into org.eclipse.ltk.core.refactoring.IUndoManager? I have pushed a small change here that seems to work but I am not sure if it has any undesired side effects: http://review.mylyn.org/#change,369.
Comment 27 Steffen Pingel CLA 2012-03-16 05:57:19 EDT
The integration tests passed. I'll put this change into the next build to include it in 3.7. Thanks for your patience, Lars!
Comment 28 Shawn Minto CLA 2012-03-16 11:53:18 EDT
I just ran a test here on windows from and it seems to work for the main use case of copying a file between folders.  There is one case where the file is still not added to the context when copying and that is when you copy a file and paste it into the same directory and need to give it a new name.  I don't think that this is as frequent as a use case, so maybe we should just have a separate issue to track this limitation.
Comment 29 Steffen Pingel CLA 2012-03-16 12:03:33 EDT
Created attachment 212795 [details]
interest levels

That seems to work for me even though the interest levels are a bit odd and it's not decorated as interesting (even though it shows in focused mode).
Comment 30 Lars Vogel CLA 2012-03-16 12:12:09 EDT
@Shawn: Copying a file in the same folder with a new name is exactly my use case and why I opened this bug. See also the original bug description in which I don't switch folders.

Hence if that still doesn't work it should be continued to be tracked via this bug.
Comment 31 Steffen Pingel CLA 2012-03-16 12:18:58 EDT
Lars, can you verify if the latest weekly build works for you? It is available from http://eclipse.org/mylyn/downloads/#weekly .
Comment 32 Lars Vogel CLA 2012-03-16 12:21:26 EDT
@Steffen: Will do, currently at the airport with less then optimal working conditions. ;-)
Comment 33 Steffen Pingel CLA 2012-03-16 13:56:29 EDT
Created attachment 212799 [details]
fix for resource events
Comment 34 Steffen Pingel CLA 2012-03-16 13:56:32 EDT
Created attachment 212800 [details]
mylyn/context/zip
Comment 35 Steffen Pingel CLA 2012-03-16 15:22:49 EDT
After looking into this further with Shawn we decided to try a slightly different approach using a an IOperationHistoryListener: http://review.mylyn.org/374. I'll kick off a new weekly build.
Comment 36 Lars Vogel CLA 2012-03-22 14:09:01 EDT
Looks good to me. Thanks for the fix, this was a very annoying bug for me.