vipmax / edgo

Yet another console text editor, but with lsp support
MIT License
32 stars 0 forks source link

Edgo saves any changes made automatically without saving by ctr+s #4

Open qwertzy-antonio-godinho opened 1 year ago

qwertzy-antonio-godinho commented 1 year ago

Hi, it seems if I open a file and type anything on it, when I ctrl+q and reopen the file the changes made are there without first having saved them explicitly.

vipmax commented 1 year ago

hi, yes, by default small files (<10k lines) are saving every time

qwertzy-antonio-godinho commented 1 year ago

Is that a feature? If it is, could it be made optional?

vipmax commented 1 year ago

Personally I don't like to save file on control+s, thus it's automatic. If you forget to save а file and everything doesn’t go according to plan I checked performance of autosave and the difference is not noticeable if file is <10k lines.

qwertzy-antonio-godinho commented 1 year ago

I'd argue this is dangerous for a text editor to save changes automatically without the user explicitly reviewing what is being saved, granted some users prefer to rely on any changes being automatically saved. My point being if there is a bug on the editor it could potentially mess the code being edited. For instance, if you rename a function in python code, edgo adds the new version of the code to the top of the file and does not clear the old version of the code leaving duplicated code. Quitting the editor saves the code (undo doesn't revert the changes to before renaming the function), when opening the file the code is messed because it was automatically saved. Please consider making this optional. Also you could add a visual mark somewhere in the screen to let users know the text was changed or when quitting some sort of message reminder to let the user know there are unsaved changes before exiting.

vipmax commented 1 year ago

Of course, autosave has downsides, but Git can help lessen them. 'Local history' feature from Intellij has saved me many times, maybe I will implement something similar for edgo.

If I turn autosave off, it will cause issues with file switching. Cause edgo can't work with multiple buffers right now, every time when you switching file, you must save changes for current file, otherwise changes will lost.

When I implement multiple buffers feature, it will be easy to make autosave optional.

qwertzy-antonio-godinho commented 1 year ago

Ok, could you please take a look then at the issue where renaming a function it does not clear the previous code and duplicates to the top of the code the new code? The steps to reproduce would be using the code sample from issue #3 put cursor where mess() function is called and rename that for instance to message. Thank you

qwertzy-antonio-godinho commented 1 year ago

Ok, could you please take a look then at the issue where renaming a function it does not clear the previous code and duplicates to the top of the code the new code? If you don't mind me asking about the buffers implementation are you going to follow vim approach to handling buffers? Not sure if you ever used mcedit comes with midnight commander, I think it's a great editor regarding handling buffers, it's similar to a "normal" editor where you have windows that can be resized providing you a "workspace". Thank you

qwertzy-antonio-godinho commented 1 year ago

This is a screenshot of mcedit editing 2 files PXL_20231007_112553736.MP.jpg

vipmax commented 1 year ago

Implementing the 'workspace' feature in edgo will require a lot of code changes. Right now it's not ready. In the future, of course, it will be possible to implement multiple buffers, split screen, resized windows, and so on. It is possible to use tmux for split screen and run multiple edgo processes. Yes, its will take more cpu and memory resources, but still not much and visually it will be the same. I use single "buffer" most of the time because of laptop screen is too small to handle two, not enough space.

vipmax commented 1 year ago
Screenshot 2023-10-07 at 6 29 39 PM

here is vertical split screen with tmux and multiple edgo processes