Unreliable undo and filetype detection
seblj opened this issue · 6 comments
I was just testing this plugin and it's awesome! However, I had some issues. I thought I could combine them into one issue instead of creating two.
The first issue I encountered, was with undoing actions. They are behaving differently while attached to the server compared to regularly. For example, if I type something, and then start undoing, it deletes one character for each undo. Normally this would undo the entire line. Also, if I delete something with 'dd', it sometimes won't let me undo this action, and says "Already at oldest change", even though I just deleted a line.
The other issue was with detecting the filetype when joining a server. If I opened a buffer with no filetype and then connected to the server, it didn't detect the correct filetype. This lead to no syntax highlighting. I could fix this issue by simply setting the filetype manually with set ft
, but it would be great if it was possible to automatically detect the correct filetype.
Thank for your useful feedback. I'll make sure to correct the wrong behaviour you mention.
-
Indeed, I very rarely use the undo for some reason in vim. Thus I wasn't aware that it saved modifications every time your exit insert mode. I pushed a commit which should modify the behaviour. Hopefully it works.
I didn't encounter bugs for line delete, maybe could you provide a reproducible example? Then I could see what's wrong. -
I'm not sure but I think this bug is only present if you're using Neovim v0.4. With 0.5, it should put the correct filetype automatically. I might be wrong and should probably look more into it.
I uploaded a small video recording of my problems. This is from just a couple of minutes ago, and I updated to the new commit that you just pushed. It seems like I can't undo at all now after the most recent commit.
Screen.Recording.2021-03-05.at.20.30.08-2.mov
The video was very helpful to debug the issue. I further narrowed down the issue to an error when the first line is restored. Hopefully the last commit will fix the issue. I probably suspect it was also the issue that you mentionned with deleting a line on a previous post.
Just tested the new commit, and the undo seems to be fixed when it comes to deleting lines. However it still seems to not behave correctly when I try to undo a line I just typed in. If I opened the same file as on the video and tries to type in the same as on the video, something strange is happening when I try to undo this. It manage to delete some characters, but then add some others. Then it suddenly shifts up a line, just as if I pressed J for join. I tried to undo a printf("testing");
under the print of hello world, and when I received the message "Already at oldest change" it looked like this:
printf("Hello World!");rippprprinritntrfint")
Hopefully this will fix the issue. I tested on my machine before committing and didn't find any wrong behaviour. I also added an automatic filetype detect
which will trigger when a client receives buffer content from the buffer. This should fix the filetype issue.
Thank you! In my small testing right now it seems to have fixed both issues. Closing this now!