kawre / leetcode.nvim

A Neovim plugin enabling you to solve LeetCode problems.
MIT License
1.04k stars 44 forks source link

[Question] My code disappeared strangely. #72

Closed shaojunjie0912 closed 6 months ago

shaojunjie0912 commented 6 months ago

When learning of data structures and algorithms, I usually write notes through code comments.

When I reopened the file via leetcode after committing the code, I found that my file was overwritten and all the code and comments I wrote earlier in this file is all gone.

Is there any way to prevent the leetcode plugin overwriting my code?

Thanks a lot!

kawre commented 6 months ago

Every time you open a question, it will reset the question if the file already existed. But this reset is not permanent, it only reset lines in buffer, so to undo it you just have to press u or :undo.

Do you have logger inside config disabled by any chance, because every time it does get reset, leetcode.nvim will notify the stuff i just mentioned above.

But I've changed it to only reset lines if status of question is accepted.

shaojunjie0912 commented 6 months ago

Thanks for the latest commit, everything is working fine now!

MasouShizuka commented 6 months ago

Can this be set as a config item? It's not very inconvenient at the moment.

In fact, I don't want leetcode.nvim to automatically reset at any time. When I need to reset, I will manually: Leet reset

shaojunjie0912 commented 6 months ago

Can this be set as a config item? It's not very inconvenient at the moment.

In fact, I don't want leetcode.nvim to automatically reset at any time. When I need to reset, I will manually: Leet reset

Have you updated the plugin? The latest version is that it will not be reset by default.

MasouShizuka commented 6 months ago

What I mean is that those questions that have passed should not be reset automatically.

MasouShizuka commented 6 months ago

As for why automatic reset is bad, take me as an example: First of all, I wrote my own ideas in the code. When I re-check the passed questions, I need to press u to reset every time, which is not convenient. In addition, I use the autosave plugin, which means that the files are automatically saved every time after reset. If neovim exits abnormally at this time, the content of the question will be lost.

So I think it would make sense to at least make this feature configurable.