-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
#10186 still a problem (Data lost during long external editing session) #10672
Comments
Isn't it because you need to configure your editor so that it overwrites the source file and not keep the changes in a separate temp file? |
Possible duplicate of #10647. See #10647 (comment) for a workaround. |
It does overwrite the source file, vim stores the file in an internal buffer while it's running and only writes when issued the write command. If the source file on disk changes in that time, it will error and give the option to overwrite anyway or reload the source file, which will then be considered a "change" to the buffer that can be undone. For example, if the note contains the text "One", I edit it and add "Two Three" on the next line and write the file, but Joplin doesn't see the change, when I click the button to end external editing and again to edit, vim will be called with the same file as last time. vim will then say that the file (which it believes is still open) is different than what is on disk. If I tell it to load, the current buffer now just says "One". If I press 'u' to undo, it will undo that load, which restores it to "One" "Two Three". Usually at this point writing again causes Joplin to see the new updates to the file and update the note. |
Interesting idea... I will try checking the mtime of the file when this happens and see if touching it solves the problem. |
No luck it seems, at least based on plain mtime:
At this point I saved the file in vim:
Then went to Joplin and found the changes were not there. I clicked the edit button twice (once to exit external editing, once to enter it) and vim presented me with an error that the file on disk was changed from the buffer. I told vim to reload the file on disk:
Then I pressed
As I was going back and forth to paste everything here, I realized the changes still were not in Joplin, so I wrote the file yet again:
This time the changes showed up in the note in Joplin. Next time I see this is triggered I'll attempt a 'touch' anyway to see if that makes a difference. |
This issue might be related to the following lines: joplin/packages/lib/services/ExternalEditWatcher.ts Lines 287 to 291 in 7e4533d
One possibility is that multiple events are received when saving a note using Vim, and that the file only has updated content after the last event (which is currently ignored). |
Removes an obsolete workaround fix for paulmillr/chokidar#591. This seems to fix external editing with Vim.
I just had a note where I opened it with no content yet (new note), wrote into it during the course of a meeting, and at the end wrote the file out in macvim. Joplin did not pick up the changes and re-read the note, so in macvim I opened a terminal window and did a 'touch' on the file. Once before when I did that Joplin then picked up on the new content, but this time it did not. So again I told Joplin to no longer edit the note externally, then clicked the edit button again which triggered macvim to "open" the file (whereby it complained that the file is already open but has changed on disk), clicked the button to load the file from disk (which is empty), pressed 'u' to undo the load (which brought back all of the content that should have been there) and wrote it to disk again. This time Joplin picked up the changes in the note. |
Based on limited testing, removing an old workaround for another bug seems to fix the issue. |
Operating system
macOS
Joplin version
Joplin 2.14.22
Desktop version info
Joplin 2.14.22 (prod, darwin)
Client ID: 49827ee4b66f4367a34c0f46ea1db6d3
Sync Version: 3
Profile Version: 46
Keychain Supported: Yes
Revision: e579eb9
Backup: 1.4.0
Favorites: 1.3.2
Current behaviour
#10186 (comment) is still a problem, I only missed the 'bump' because I was out on vacation. Happens almost daily when I'm using the program.
Lately I've taken to, while in vim, writing the file and going back to Joplin to see if it's updated. If not, I click the button to turn off external editing (without closing the editor), then click again which triggers vim to try to reopen it and say that the file on disk has changed. I tell vim to go ahead and load the "new" file, then press 'u' to undo the changes (going from the correct version in the buffer to the old version on disk, then back to the correct version that was in the buffer), and write again. Usually that causes Joplin to pick up the changes on disk. But if I'm not careful the changes that the editor wrote will still be lost.
Expected behaviour
No response
Logs
No response
The text was updated successfully, but these errors were encountered: