drracket icon indicating copy to clipboard operation
drracket copied to clipboard

Editor should reload if file changed on disk

Open EmileSonneveld opened this issue 7 years ago • 20 comments

When changing a file that is opened by the editor, the editor should detect this and reload the file. If there are local changes, the user should be prompted to reload or not.

This is especially handy when doing a git-pull, or after an advanced find-and-replace from within another editor. (Didn't find a way to auto-refresh in 6.10 and 6.12)

Ps. Thanks for making programming in scheme delightful with Dr Racket! :D

EmileSonneveld avatar Mar 25 '18 12:03 EmileSonneveld

I have considered adding this check but doing it only on the first edit of a file -- more precisely, when drracket thinks the buffer is not modified (saved) and an edit to the buffer happens, check to see if the file on disk has changed and, only in that case, prompt the user.

I think this would be a fine mixin to add to the framework (in the racket/gui repo) that it would make sense to use in drracket.

rfindler avatar Mar 25 '18 13:03 rfindler

Glad it was considered already :) I guess it would make more sense to always check this when the window is focused. (With a file-watcher) It could be frustrating to get a popup as soon as you begin typing some code. (Sublime-Text and Visual Studio do it like this I think)

Apparently, the buffer is checked when pressing "Run". This is feels like a late.

EmileSonneveld avatar Mar 25 '18 18:03 EmileSonneveld

Yes, indeed sublime seems to have a different, much more aggressive setup. If the buffer isn't dirty, it just changes the content of the editor when the file changes. If the buffer is dirty, it prompts, popping up the prompt when you are possibly in the middle of other edit operations.

The plan above is an attempt to copy what Emacs does, fwiw.

rfindler avatar Mar 25 '18 20:03 rfindler

Personally I really like the behavior of some editors where they refresh changed files automatically without requiring user interaction as long as you have no unsaved changes for that file. It feels seamless and works as I subconsciously expect "computer stuff involving files" to work. But I save reflexively when editing code, so I rarely have unsaved changes that would cause conflicts.

jackfirth avatar Mar 27 '18 19:03 jackfirth

Okay, lets declare that to be the official plan, then! Not sure when I'll have time to get to it, but at least I know what I'm going to do.

rfindler avatar Mar 27 '18 19:03 rfindler

has this made it to the todo list? There is another benefit of this that is not mentioned above. Users who prefer other editors can edit over there, swap back to Dr.Racket have the reload happen, and then run and use the REPL below. If approving a reload can happen via keyboard or isn't needed then this can be a very fast process.

masukomi avatar Jun 27 '20 22:06 masukomi

I didn't really realize just how close 7.8 is so I'm tempted to revert this change until after branch day, so we have a full release cycle to get experience with it in case something is catastrophically wrong that I didn't see. Any thoughts?

rfindler avatar Jul 01 '20 16:07 rfindler

This did break a bunch of DrDr tests, for whatever that's worth.

samth avatar Jul 01 '20 17:07 samth

Yeah, it is broken :( I've reverted it for now.

rfindler avatar Jul 02 '20 04:07 rfindler

FWIW, I'm totally psyched about making this change, I do run into this all the time. So... looking forward to it! (after branch day)

jbclements avatar Jul 02 '20 12:07 jbclements

This is not on master yet, but if you raco pkg update --clone drracket and then use git commands to move that over to the enabling-autoload branch you can try out the current state. I don't know of any more problems. (The one I was stalled on for a while had to do with spurious filesystem change evt wakeups that didn't seem to be coming from anywhere in the GUI libraries or in DrRacket -- I gave up trying to find them and am using sha1 now instead to check them.)

Would love to get a few more people than just me trying it, @jbclements @jackfirth (and maybe @samth ?)

rfindler avatar Aug 19 '20 00:08 rfindler

I'll give it a shot tonight.

jackfirth avatar Aug 19 '20 00:08 jackfirth

This did get merged, right? Should this issue be closed?

samth avatar Feb 01 '22 20:02 samth

I don't think it did. There are some issues that I haven't been able to track down but I'm forgetting what they are right now. Something with the teaching languages, maybe?

rfindler avatar Feb 01 '22 20:02 rfindler

A problem was described in https://github.com/racket/drracket/commit/b4bb32dffee586a1c78ea8304121c9754a679141 which revered the mentioned commit. There are some subsequent commits that might be related but it's hard for me to tell what's going on.

samth avatar Feb 01 '22 20:02 samth

I think the main status is that the code is there in the framework but it isn't turned on in drracket.

rfindler avatar Feb 01 '22 20:02 rfindler

Hey! is the feature available yet? It gets super inconvenient to close the file and open it again for the changes in files to reflect.

mantrakp04 avatar Nov 05 '22 16:11 mantrakp04

No, sadly.

But you can use menukey-shift-E to lessen the pain for the time being.

Robby

rfindler avatar Nov 05 '22 16:11 rfindler

By any chance is it possible to search up help desk without opening browser just on drracket

mantrakp04 avatar Nov 06 '22 04:11 mantrakp04

@samth I believe that the current state is that the implementation of autoload is mostly in the racket/gui repo, in editor:autoload-mixin but that it does not work correctly currently. This commit merely turns it on in DrRacket (and adds a test case and some docs). I'm not sure what the extent of the buginess of editor:autoload-mixin but it definitely needs more testing and I'm pretty sure there is an interaction with the teaching languages that's wrong. (There may also be more that's wrong.)

rfindler avatar Nov 07 '22 03:11 rfindler