Cudatext save a file externally modified by another process

Solved bugs are moved into this topic...
Post Reply
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Cudatext save a file externally modified by another process

Post by gh_origin »

Currently I found Cudatext can't save a file as the content displayed on the editor currently if the file is modified by another external process. It asked me if I want to reload or just cancel. I chose cancel and press Ctrl+S then quit Cudatext. I open the file in another text editor (Pluma) and the content is not the original content displayed on Cudatext but the content overwrote by the external process. In the other words, Cudatext doesn't save the text at all. Neither Ctrl+S or File/Save work.

The standard behavior on other editors is if I refused to reload the new content of the file from the disk and still choose the save the content currently displayed by the editors, they will ask me if I really want to save the file and if I choose yes it will save the file as my request. I don't know if it's Cudatext's non-standard behavior or it's really a bug.

How to reproduce: if you play Supertux2, when you opened the .stsg file at $HOME/.local/share/supertux2/profile1 to apply the hack, save the file but do not close the editor. After you played a while, you exit Supertux2 and the editor will ask you to reload the file or cancel because it was externally modified. The rest is already reported in detail above.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

How the message about "do you want to reload" looks like? top panel embedded to editor? or msg box?

give steps pls: e.g. 1) run the game, 2) run the Cudatext during the game 3) save file in Cud, 4) exit game...
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

did you check file content after Cud save command? ie save, run file manager, open file in GEdit?
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Everything you need here. Cudatext's behavior when dealing with file changed by external process is a bit buggy. I will show in my next post.
Attachments
The file content after already 'saved' by Cudatext
The file content after already 'saved' by Cudatext
The warning when file changed by an external process
The warning when file changed by an external process
The editor when I click Cancel to not reload the find and save the content currently displayed using Ctrl+S
The editor when I click Cancel to not reload the find and save the content currently displayed using Ctrl+S
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Cudatext behavior about a file being externally modified by Pluma.

Long story short: It seemed Cudatext constantly reload the file content from disk, without user intervention. Even though sometimes it not update the displayed text to match the file content (when the text file is big enough like the Supertux2's .stsg game save? it updated the content of my one line test file immediately), it already loaded the modified file content. The warning it displayed to ask the user's opinion is just to ask for the sake of asking. When the user choose to Cancel reloading, it still has the modified file content (maybe loaded in memory?) even though not updating the displayed text. So when issuing Ctrl+S, there is nothing to save, as the content now (the modified content) is already matched to the file on the disk!

Workaround: Cudatext's Cancel button is not reliable. It's not enough to click Cancel and just issue Ctrl+S. You have to enter a character into the displayed text then delete it and issue Ctrl+S. The file will be saved as expected.
Attachments
Cudatext updates the content automatically without asking the user if he wanted to reload the content or not
Cudatext updates the content automatically without asking the user if he wanted to reload the content or not
Edit and saved by Pluma when still opening on Cudatext
Edit and saved by Pluma when still opening on Cudatext
The file content opened by Cudatext
The file content opened by Cudatext
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

>Workaround: Cudatext's Cancel button is not reliable. It's not enough to click Cancel and just issue Ctrl+S. You have to enter a character into the displayed text then delete it and issue Ctrl+S. The file will be saved as expected.
I got it. Cud has "Cancel" pressed, and it don't mark file as modified. so Save command is ignored! so Ctrl+S does nothing. to make Save, you need some modification (add char, delete char).
do you suggest to mark file as 'modified' on pressing Cancel in file-reload-panel?
I am not sure it's correct - file is not modified in Cud (it's modified by external app).

1.114 will show statusbar text "Save command is ignored" when ctrl+S is ignored.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

fixed by adding the new option

//Command "File / Save" works always, even with unmodified state of document.
//Otherwise, it works only for modified (dirty) documents, of if the file was deleted outside.
"ui_save_always": true,
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Thank you. This Beta version works as expected. BTW, I hope the next official release would have the QB64 lexer :)
Post Reply