jbang icon indicating copy to clipboard operation
jbang copied to clipboard

fix: Prevent jbang edit --live from entering endless loop

Open quintesse opened this issue 3 years ago • 12 comments

Also using links now for files with improper names.

Fixes #1027

quintesse avatar Sep 30 '21 14:09 quintesse

Darn, the link change doesn't work because now the watch doesn't detect any changes :-)

So what to do now @maxandersen ? Set the watch on the original folder perhaps?

Edit: Or even on each of the edited files instead of the folder.

quintesse avatar Sep 30 '21 15:09 quintesse

Wait - why does this change affect watch? Watch if java files work so why would that change for differently named files ?

maxandersen avatar Oct 01 '21 14:10 maxandersen

Because right now they get copied to the jbang cache with a "proper" name and then that copy is being used by edit. So the edits never end up back in the original file. This must have been like this for a long time already because that mechanism is pretty old.

So that's why I thought to change it to using links instead of making a copy, but then the watch doesn't work anymore (because links don't change when you edit the file they point to, obviously). So then the next step would be to not watch the temp project folder but the actual individual files. Because that way you can watch the original file (called abc-def) but give the link (named AbcDef.java) to the edit command.

It sounds all a bit complicated perhaps, but it should work.

quintesse avatar Oct 01 '21 14:10 quintesse

I'll need to look as I've been using edit for ages and the edit happens on original file not cache.

maxandersen avatar Oct 01 '21 15:10 maxandersen

I'll need to look as I've been using edit for ages and the edit happens on original file not cache.

Sure, but you perhaps never did on files with invalid names?

quintesse avatar Oct 01 '21 21:10 quintesse

im not questioning that invalid names have an issue just not grokking why file watching wouldn't work just because the filenames changes... myapp.java is also symoblically linked...not copied.

maxandersen avatar Oct 01 '21 21:10 maxandersen

myapp.java is also symoblically linked...not copied.

They're symbolically linked into the cache/project folder , yes. But before that happens files with illegal names are first copied to a file with a "proper" name under cache/scripts... and then they are linked to cache/project. So it's a double indirection.

quintesse avatar Oct 01 '21 22:10 quintesse

okey I grok the issue now - yeah; there aren't a good real quick fix - we'll need to skip the caching when editing and then do rename via link.

maxandersen avatar Oct 02 '21 08:10 maxandersen

we'll need to skip the caching when editing

Hmm that's probably going to be ugly in some way because that's pretty deep down into the ResourceRef code. And when you start getting into those weird little opt-outs for special cases it often means you have the wrong abstraction.

So why not watch the original file (before rename) as I suggested? Wouldn't that be an option?

quintesse avatar Oct 02 '21 10:10 quintesse

Yes that could work.

maxandersen avatar Oct 02 '21 11:10 maxandersen

@quintesse you Wanna finish this one ?

maxandersen avatar Oct 12 '21 04:10 maxandersen

Will do. 👍

quintesse avatar Oct 12 '21 09:10 quintesse

@quintesse still an issue you wanna fix? if yes - lets keep it open but if not lets close it to not take up mental space :)

maxandersen avatar Jan 13 '23 13:01 maxandersen

I'm okay with closing it 👍

quintesse avatar Jan 13 '23 15:01 quintesse