IDE External file modification detection - a solution

Hi All

The IDE’s handling of external file modifications is rather annoying - it mostly only detects modifications when it receives the focus - and then it prompts even when the file is open but unmodified.

Reported as RSS-4316

My solution for RS 12+ (until the IDE fixes this properly) :smirking_face:

https://github.com/VSoftTechnologies/VSoft.ExternalModDetector

It uses Kiriakos Vlahos’s (RIP :cry: ) FileSystemMonitor library (which uses the ReadDirectoryChanges windows api) to detect changes, and the tools api to reload files.

My hope of course is that the 14.0 IDE will make this redundant :crossed_fingers:

3 Likes

There is an option to auto reload files modified outside of the IDE without asking (Tools, Options, Editor, disable Ask to reload modified files) but yeah, it still has the focus issue. Nice to see a work-around and hopefully it makes it into a future release! Keep up the good work :smiley:

We use a unit published in 2013 by “Luthfi” for file monitoring (source for that appears to no longer exist). It uses the ReadDirectoryChangesW function and works in (at least) D10-12.

Hi Jarrod

From memory, the problem with that option is that it will reload files even if they are open and modified in the editor - potentially losing changes. I made the plugin only reload files if they were not modified in the ide - those will still prompt when the IDE gets the focus again.

Also, the IDE sometimes doesn’t reload files that are not actually open in the editor - I haven’t been able to narrow down a test case, but I have had several instances of the IDE caching files and not using the changed version on disk - I had to close the project and re-open it to pick up the changes.

I guess when the delphi IDE was created the ReadDirectoryChanges function didn’t exist (before Windows XP) - and they just haven’t bothered to update the change detection. They are aware of this - at least Bruneau is - however I see my report still hasn’t been validated, so not holding my breath for it being addressed.

It definitely prompts for me “file changed, reloading will overwrite changes, do you want to continue?” but I don’t know how reliable that is - I am normally very careful to sync my changes and don’t typically carry on editing in the IDE while AI is making other changes.

Any improvements would be appreciated though - perhaps even auto merge or open in diff view when this happens instead of having to choose one version or the other without being able to compare.

I like this idea, when time permits I’ll see what claude can do :smirking_face:

1 Like

What keeps bugging me every year is the daylight savings time change, when you leave Delphi running overnight and it starts prompting you for every file and you no longer have any idea if you modified anything after the last save.

Alex

1 Like

Yeah I guess that is a pain - not sure how they would fix that, I guess the change detection code needs to know if it has gone through a timezone change. Is there a Jira report for this?

The “don’t prompt if a file changes outside the IDE” setting might fix that

It’s a catch 22: sometimes you really do not want these prompts and sometimes you really do, but the IDE can only do one thing…

Alex

Isn’t that what AI meant to predict? :smiley: