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

Showing a diff sometimes crashes vim on windows #7

Closed
TimUntersberger opened this issue Sep 12, 2020 · 18 comments
Closed

Showing a diff sometimes crashes vim on windows #7

TimUntersberger opened this issue Sep 12, 2020 · 18 comments
Labels
bug Something isn't working

Comments

@TimUntersberger
Copy link
Collaborator

This is probably an upstream bug. Sometimes toggling a diff for the first time can crash neovim when creating the fold

@TimUntersberger
Copy link
Collaborator Author

TimUntersberger commented Sep 12, 2020

@bfredl do you know what could cause this? I can sometimes reproduce this 100% (when certain conditions are met, which I don't know yet) on windows, but never on linux.

Doing <from>,<to>fold is the source of the problem.

I can record a video for you if this could help you.

@hkupty
Copy link
Contributor

hkupty commented Sep 15, 2020

To me, on linux, it gives me a segfault if I enable diff 3/4 when I have something staged. I'm not sure it's the same issue, but definitely it looks like so.

@TimUntersberger
Copy link
Collaborator Author

To me, on linux, it gives me a segfault if I enable diff 3/4 when I have something staged. I'm not sure it's the same issue, but definitely it looks like so.

Can you reproduce this with a different repo? For me this is happening completely random and I don't know what the problem is.

@hkupty
Copy link
Contributor

hkupty commented Sep 15, 2020

It happened to me on three different repos, one being this, one being my dotfiles and another is a java codebase. Completely different repos.

@TimUntersberger
Copy link
Collaborator Author

Is it always the same position (like 4th staged change or something like that)?

For me it has happend when only 1 file was unstaged or when I had a lot of files open.

@hkupty
Copy link
Contributor

hkupty commented Sep 15, 2020

1 or more staged, sometimes not even staged, but I guess it's probably something else. Im assuming it's on gits side, when getting the patches, rather than on displaying...

@TimUntersberger
Copy link
Collaborator Author

It has to do something with fold though. When I remove the folds it doesn't crash anymore. This is overall very weird.

@hkupty
Copy link
Contributor

hkupty commented Sep 16, 2020

Modified lua/neogit/status.lua
@@ -59,7 +59,7 @@ local function insert_diff(section, change)
     return
   end
 
-  vim.cmd("normal zd")
+  --vim.cmd("normal zd")
 
   if not change.diff_content then
     if section.name == "staged_changes" then

Ok, I've isolated it to this line. When I comment this command, it never breaks for me.

@hkupty
Copy link
Contributor

hkupty commented Sep 16, 2020

I don't know the intent of this zd command, but it seems from my manual testing that neogit works well without it.

@TimUntersberger
Copy link
Collaborator Author

TimUntersberger commented Sep 16, 2020

zd deletes the fold under the current line. I honestly don't remember why I delete the fold under the current line. Do you know of any way to get a backtrace for the vim crash? The debug and log features don't really return anything useful for me.

Edit: I think we need zd, because each change has an empty fold in the beginning, which has to be deleted (I think).

@hkupty
Copy link
Contributor

hkupty commented Sep 16, 2020

I found that by accident by manually running zd and getting an error message (something like no fold to be deleted). Is there a way to check if there's actually a fold there before you run zd?

Do you know of any way to get a backtrace for the vim crash?

Unfortunately no.

Another alternative would be to test without the shorthand version vim.cmd, using vim.api.nvim_command. this can be helpful to isolate where is the issue.

@TimUntersberger
Copy link
Collaborator Author

I just tested without the zd and it still crashes for me. I only don't crash when i remove the create_fold calls.

@TimUntersberger
Copy link
Collaborator Author

Manually doing the <start>,<end>fold excommand with the same arguments also crashes neovim for me, so this has to do something with neovim.

@hkupty
Copy link
Contributor

hkupty commented Sep 16, 2020

Ok, so maybe we're having different issues on Windows and Linux :/

@TimUntersberger
Copy link
Collaborator Author

which neovim version are you using?

@hkupty
Copy link
Contributor

hkupty commented Sep 16, 2020

I've been using master, latest build from today.

@TimUntersberger TimUntersberger added the bug Something isn't working label Sep 16, 2020
@TimUntersberger
Copy link
Collaborator Author

@hkupty are you still encountering the issue? I haven't had this bug in a while and thinking about closing this issue.

@hkupty
Copy link
Contributor

hkupty commented Jan 28, 2021

Been using for a while, didn't seem to happen anymore. I guess it should be safe to close it, sorry for the delay in answering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants