New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First draft of 'file_externally_changed' RFC #1164
base: master
Are you sure you want to change the base?
Conversation
8e3d0d3
to
2e852e0
Compare
So the way I would encourage thinking about this is as a sort of two-part question.
So given those questions, do you have an opinion of what approach might be best? |
As detailed in the RFC, there are two ways to handle it: a) Notify immediately on change and reload or don't reload and overwrite
IMHO we should go on as described in the RFC: Have a For a) and b) we only need the previously mentioned For c) we need what a) needs and a way to communicate to the frontend that saving has failed (which might be a good idea in general) |
Will focus on the first part for now:
It's not clear what "don't reload and overwrite" means. Does this mean that if a file changes on disk we would immediately overwrite it, without notifying the user? I don't think this is what you mean, but it's not clear.
What is the difference (in terms of the experience of the user) between these two options? |
It means that the user doesn't reload (just keeps on editing) and on save overwrites the (changed) document.
From my POV b) is better, since I'm (the user) am only asked one question, which has all the possible options for me. There's no need to press a button and wait around if that worked and if not press another button in a new dialog again like in c) |
I think we can rule out this option, on the principal that we should not ever silently overwrite user data.
Core knows whether or not a change has occurred; there's no calculation involved. Given this, core should be able to respond instantly (in human time scales) and so immediately after 'save' you would see the dialog indicating that there had been a change. This is the sense in which I think these two are equivalent, from the perspective of the user? (They are subtly different for the frontend author, granted) |
Maybe a combination of a+c would be best then? So notify the user on change and offer to reload and also notify on save that a change has occured?
Ah, sorry, didn't do a good job communicating what I meant there. I mean that the user has to press 2 buttons instead of 1, read 2 dialogues instead of one (first "Do you want to save?" and then "Do you want to overwrite" and if he answers no to that has to click through the previous dialogue again). So it doesn't need a lot of computer time nor is it complex to implement for frontends, but rather it needs a lot of human time (compared to b). |
I think I'm still confused, though. What would happen in c is that the user would send |
Derp, I think my brain is a bit fried from cramming so much math into it, somehow I was sinking about the save dialog that's usually displayed when you attempt to close the editor but still have unsaved chsnges. You're right, usually there'd only be one dialog! :) |
Okay cool, glad we're on the same page. |
Pushed a cleaned-up version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, looking back over this I think it's a reasonable approach.
I think it would be nice to figure out exactly what the new RPCs will be / what their arguments are, so that could be something to add? Otherwise I think it's reasonable to start working on this.
One inline suggestion: it might be worth separately working on making save
be a request RPC (that requires a response) so that we can consistently report success/failure.
|
||
1. | ||
If the frontend sends 'save' with 'force: false' and the file has been changed | ||
externally, then Xi should send another notification back, e.g. 'save_failed' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that probably save
should report errors in general; I think it makes sense for save to become a request
. Maybe this would be a good first step for this work? We would want to support the existing API fro the time being, but we could have both notification & request live alongside one another for a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we could have both notification & request live alongside one another for a while.
Hm, can they also share a name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have to check, but I think so; we separate notifications from requests early (based on the presence of the id
field) so this should work. Let's try it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, will adjust the RFC in a bit! :)
1c784c1
to
7c3cd02
Compare
S one last thought on this: normally (in other editors) when you get the notification that the file has changed, this doesn't happen in response to a save request. So: I think there are different possible 'flows' in response to a notification of an external change, versus attempting to save. I would expect your options to in response to an external change to be "ignore/reload", and then if you ignore and attempt to save later that will still fail, unless you've included More and more this makes me think that |
Well, there are different approaches to this (see the comparision under
Not quite sure if I understand, you want the Frontend to remember if saving has failed for this to work?
Very much so, at least Tau currently manually checks if the file is readable, which is should definitely be handled by Xi. |
Yes, this will require the notify feature. What I mean is: even when an editor does receive file change notifications (my vim does this) this is handled differently, with different options, then when a file change is detected only after attempting to save.
The frontend doesn't have to remember; when it goes to send
Yep, so if part of this change introduces a |
7c3cd02
to
7c99a41
Compare
Yes, but isn't that the job of the frontend? I'm a bit confused as to how this should be handled here. Anyway, updated the RFC quite a bit. |
Relevant to #1126 and #1140