Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jeremypw
Copy link
Collaborator

@jeremypw jeremypw commented Mar 23, 2023

Fixes #17

In master, if AUTOSAVE is on and external changes are made to an open document these changes are immediately imported into that document as soon as it is focused whereas if AUTOSAVE is off then an infobar is shown. It is unclear why there should be this difference in behaviour so this PR always gives the user a choice of reloading the document or overwriting the external changes.

  • Show infobar when external changes detected regardless of AUTOSAVE setting
  • Instead of "Continue" give "Overwrite" option
  • Hide infobar only after document either reloaded or saved so conflict resolved
  • Autosaving inhibited until conflict resolved
  • More extensive information in infobar, formatted to fit half-tiling

Note that the current infobar is limited to two options with a horizontal layout so is not ideal for fitting into half-tiled window. As a conflict with an external edit could be considered a corner case no attempt was made to use a different widget here. The third "Save As" option already exists in the headerbar anyway.

The infobar might be considered too verbose in which case alternative text suggestions welcome.

Screenshot from 2023-03-24 11 32 05

@jeremypw jeremypw changed the title Ignore external changes after selecting "Continue" Improve handling of external changes Mar 24, 2023
@jeremypw jeremypw marked this pull request as ready for review March 24, 2023 11:33
@jeremypw jeremypw requested a review from a team March 24, 2023 11:33
Copy link
Contributor

@zeebok zeebok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. I will give this a good test tomorrow!

Jeremy Wootten added 2 commits March 27, 2023 13:41
@zeebok
Copy link
Contributor

zeebok commented Apr 16, 2023

Phew tomorrow took a bit to arrive but I did start testing! I did notice some things:

  1. If I create a new file in Code and save it, edit it in terminal and return to code, it will not detect the changes and give me the option to reload. If I try to make changes and save (either with autosave or not) it tells me it cannot save the changes
  2. If I get into the state in Issue 1, I cannot close the document tab. In fact, I need to kill Code because I can't even close that
  3. These issues do not occur if you open an existing file in Code

@jeremypw
Copy link
Collaborator Author

@zeebok Thanks for looking at this! I am pretty sure it worked better than that when first pushed 😞 maybe the last merge messed it up. I'll have to see how this PR works with #1307 / #1308 too as there maybe some overlap.

@jeremypw
Copy link
Collaborator Author

@danirabbit In view of your comments on #1307, is this something that would also be better done with a dialog? The infobar now contains a lot of information in this PR.

@jeremypw
Copy link
Collaborator Author

@zeebok

If I create a new file in Code and save it, edit it in terminal and return to code, it will not detect the changes and give me the option to reload.

This is expected - Code does not continually monitor the file on disk, it only checks the file status when an edit is made and autosave is ON, or when a save is attempted. However, I confirm that the behaviour after a save attempt is made is unsatisfactory - no reason for the save failure is given. This in fact was the motivation for #1307 as it was happening under other circumstances.

The whole system for saving files in Code is quite tricky to work on.

@jeremypw jeremypw marked this pull request as draft April 16, 2023 10:11
@jeremypw
Copy link
Collaborator Author

Converting to draft pending decision regards dialog and whether to incorporate in #1308 (or at least develop together)

@zeebok
Copy link
Contributor

zeebok commented Apr 17, 2023

This is expected

But it does appear to do it with a file I load. I load a file in Code, edit it externally, and I get the message when I go back to Code.

@jeremypw
Copy link
Collaborator Author

But it does appear to do it with a file I load. I load a file in Code, edit it externally, and I get the message when I go back to Code.

Hmm, OK. Not sure why that should be but there are a lot of moving parts involved. I'll make sure to include the two possibilities in my testing. Hopefully #1309 handles this better.

@jeremypw
Copy link
Collaborator Author

@zeebok It seems your issue is caused by the "focus-in" handler not being connected for new documents after they are saved - fixing.

@jeremypw
Copy link
Collaborator Author

Closing in favor of #1309

@jeremypw jeremypw closed this May 25, 2023
@jeremypw jeremypw deleted the fix-external-edit branch June 23, 2023 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"File x was modified..." infobar keeps showing after continuing to edit the file

3 participants