eteran / nedit-ng

a Qt5 port of the NEdit using modern C++14
GNU General Public License v2.0
95 stars 26 forks source link

File modification indicator #104

Open marilmanen opened 5 years ago

marilmanen commented 5 years ago

Here is a description of a new feature that I would like to have (I had it in the old NEdit).

When a user starts to modify a file, an empty file with additional identification is created to the same directory (in case the user has write permission to the directory). When the user saves changes, cancels modifications or saves the file with a new name, the empty file is removed. Identification could be for example -nedit- to reduce risk of overwriting some real file.

Usage example: I use automatic source file handling to collect files from different locations. If I have modified a file, but forget to save it, the automatic source file handling tool checks if those empty files exist and issues a warning. This feature has saved me a lot of time as non-saved changes can cause a lot of confusion and are many times a bit difficult to find.

eteran commented 5 years ago

You say that you had it in the old NEdit, but I am unaware of this feature. Was it a 3rd party patch?

marilmanen commented 5 years ago

It was a modification that I did on the source files, but I was not confident enough to publish the change. Now this sounds stupid as the feature has proven to be very useful.

eteran commented 3 years ago

Revisiting feature requests.

If I understand this correctly, you are basically asking for a "lock file", right? The idea is that the file serves as a marker that an editor is already editing that file.

Likewise, if you aren't using nc, nedit could detect the presence of this lock file and warn the user that an instance of nedit already has that file open.

Do I have that right?

marilmanen commented 3 years ago

Just having a file open in nedit should not create the modification indicator file. I would like to have a indicator file only when I have made modifications to a file, but have not yet saved the modifications. When the modifications are saved (or canceled by undo) the modification indicator file should be removed. Practically the modification indicator file should exists at the same time when the editor window title indicator has the "(modified)" label.

eteran commented 3 years ago

So kinda like the vim .swp files then?

marilmanen commented 3 years ago

I get the .swp file as soon as I open a file in write mode and I want the file only when the file is under modification. The swp file is also not just an empty file, so I think it could also have issues when handling large files.

eteran commented 3 years ago

Gotcha, I think I understand what you're looking for now.

anjohnson commented 3 years ago

Could this just be the backup file (~<filename> on my systems)? I'm not sure exactly when it gets created but it sounds like almost the same behavior to me.

marilmanen commented 3 years ago

Issue with the backup files is that they are not empty (cause slowness when handling large files and thus should not be enabled by default) and those are not always immediately removed when a file modification status changes back to unmodified state.

I'm having many times much more speed than I can handle and thus I forget to save some of the files I've modified. Then I compile my HDL files and run simulation and spend long hours debugging and wondering why the modification I just did had not the expected impact. After all possible causes have been checked I get back to the source file and notice that I have not saved the file and at this stage I'm not very happy with myself. To avoid those days I have created a pre compile and simulate script which gives a warning if any modification indicator files exist for the source files I'm about to compile or simulate.