Skip to content
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

Editing new file will reuse the file name of previously opened file #228

Open
Vrihub opened this issue Mar 26, 2024 · 5 comments
Open

Editing new file will reuse the file name of previously opened file #228

Vrihub opened this issue Mar 26, 2024 · 5 comments

Comments

@Vrihub
Copy link

Vrihub commented Mar 26, 2024

Steps to reproduce:

  1. Open an existing file. Don't enter edit mode.
  2. Tap on the "+" icon to open a new file. You get an empty buffer with the Untitled.txt filename
  3. Tap on the pencil icon to enter edit mode

Expected result: you should be editing the new Untitled.txt file.

Actual result: as soon as you enter edit mode, the current filename reverts to the name of the file you opened in step 1. above.

WARNING: potential data loss. If you don't realise this and click on the Save icon, the old file will be silently overwritten.

Suggestions:

  1. Fix this bug
  2. Add a confirmation prompt before overwriting existing files.
@billthefarmer
Copy link
Owner

Unable to reproduce. Tested on three different devices.

@Vrihub
Copy link
Author

Vrihub commented Mar 30, 2024

Interesting. I Get the bug if I open the file in step 1 in one of the following ways:

  • Click on a txt file in my android file manager (configured to open txt files with Editor)
  • Click on a link to a txt file on my home screen

I can't reproduce the bug if I open the file in step 1 via Editor's "Open file" menu.

So the way the first file is opened seems to matter.

I'm running f-droid's latest editor package on Samsung android 11.

@billthefarmer
Copy link
Owner

See the README. File managers and other apps use a content URI to share files which may not be resolvable to a path to a real file and may be read-only. That is why I wrote the file picker, to get around the idiosyncrasies of file managers, other apps, and android making it difficult to access the file system.

@Vrihub
Copy link
Author

Vrihub commented Mar 31, 2024

So it seems the bug lies in this mechanism you devised to overcome android's limitations in saving files. It is a bit too over-zealous in the scenario I described, wrongly re-using the old filename and overwriting the old file when the user saves.

Once the user chooses to edit a new file, the past shouldn't matter and editor should stick to the default filename for new files.

(BTW I never had any problems with saving files, but maybe I was lucky with my android version)

@Vrihub
Copy link
Author

Vrihub commented Apr 12, 2024

This bug seems fixed in 1.96 thanks!!!

I've now noticed another couple of bugs while using the Save as... feature to overwrite an existing file.

Steps:

  1. Open a file and edit it.
  2. Choose Save as... and enter the name of an already existing file

Expected: get a warning message like "File FOO already exists. Do you want to overwrite it?"

Actual: the message says "This file has changed. Do you want to overwrite it?"
The original file has obviously been changed, while the target file (about to be overwritten) has not been changed. This message only makes sense if one chooses Save as... and enters the same name of the original file.

But there's more. If you now choose to overwrite: the new file name will appear in the upper left corner, but the file is still saved to disk under the old filename, while the file chosen to be overwritten is left untouched. This keeps happening every time you hit the Save icon.
Incidentally, pressing the android "Back" button to switch to another app, then switching back to the editor gets you back to the file and restores the old original filename in the upper left corner.

Expected: the original file should be left untouched, the chosen file should be overwritten with the current buffer content, and the new filename should appear permanently in the upper left corner (until the next Save as... action).

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

No branches or pull requests

2 participants