Page 1 of 1

Cudatext save a file externally modified by another process

Posted: 01.10.2020 17:00
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.

Posted: 02.10.2020 13:25
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...

Posted: 02.10.2020 13:31
by Alexey
did you check file content after Cud save command? ie save, run file manager, open file in GEdit?

Posted: 02.10.2020 14:26
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.

Posted: 02.10.2020 14:43
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.

Posted: 04.10.2020 08:00
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.

Posted: 04.10.2020 09:09
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,

Posted: 04.10.2020 09:32
by Alexey

Posted: 04.10.2020 16:42
by gh_origin
Thank you. This Beta version works as expected. BTW, I hope the next official release would have the QB64 lexer :)