[TxMt] Re: File changed status wrong when modified by a bundle command

Eduardo Francos efrancos at efrancos.com
Sun Aug 17 08:46:30 UTC 2014


On 15 août 2014, at 12:39, Allan Odgaard <mailinglist at textmate.org> wrote:

> Starting a new thread should not be done by replying to an existing letter and changing subject. It messes up threading for software that uses the in-reply-to email headers.

Sorry about that. I should have known better :p

> 
> On 10 Aug 2014, at 8:30, Eduardo Francos wrote:
> 
>> I'm writing a bundle command that increments the build number of a project by modifying one of the project's files.
>> When that file is the currently active one in TM then TM will detect the change and reload the file, but it will also set the changed status to true.
>> This does not happen if the file is not the currently active one even if the file is opened in another tab, nor does it happen when the file is modified by a different process (ex: vi)
>> 
>> Is this the intended behavior?
> 
> It does not sound like it, but I have seen it myself occasionally, where a file has no changes but is marked as modified. I think mostly when using Git → Revert for an open file.
> 
> The way TextMate tracks changes on disk is something I would like to rework. But if you have steps-to-reproduce with 100% certainty, please do share.

As I said before the problem occurs only when the version file is modified by a command AND it's the currently active tab.
Running the command when it isn't the active tab is OK, as it is when modifying the file with an external program.

I've included a simplified zipped "project" folder that contains:
- A plain text "version.txt" file with the current version number
- A dummy README.txt file so you can have another file to open
- A simplified version of the "Increment Version.tmCommand" that increments the current version number in the ENV['TM_PROJECT_DIRECTORY']/version.txt file.  (key: ^⌥⌘V)

Add the command to a TM bundle of your choice and open the folder as a project.

Test cases when executing the command:
1) The version.txt file is opened in TM but it's not the currently active tab:
No problem, the file is reloaded and its status remains unmodified

2) The version.txt file is opened in TM and it is the currently active tab:
The file is reloaded but is marked as modified... most of the time
The bad news is that when repeatedly running the command at ~2 seconds interval I found that ~8 out of 10 times the version.txt file is reloaded with the new contents but its status is incorrectly set to modified, but for the other 2 it works as expected. This could mean there is a race condition type of problem between the execution of the command and whatever system you use to track file changes on disk. Probably not easy to debug :-(


Please let me know if I can be of any help.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: FileStatusBug.zip
Type: application/zip
Size: 1391 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20140817/2a1e67b9/attachment.zip>
-------------- next part --------------




More information about the textmate mailing list