ThePrimeagen / harpoon

MIT License
6.25k stars 348 forks source link

fix: #570 native swap file error suppressed #571

Closed dabstractor closed 2 months ago

dabstractor commented 2 months ago

Closes #570

kimabrandt-flx commented 2 months ago

@dabstractor Did you try to get rid of the red-colored exception, after the dialog? I like this solution better than the one suggested in comment, if the exception went away :)

dabstractor commented 2 months ago

@kimabrandt-flx The 2nd screenshot I posted with the red error message was after opening the file with the default built-in file browser. This is the default Neovim experience. So even though it's obviously an eyesore I don't believe there's anything to "fix" per se. This is just how Neovim behaves.

I do believe this operation requires proper error-handling, though, in order to prevent opening the file with an existing swap if the user chooses to [Q]uit or [A]bort from this point, but my gut tells me that getting rid of an error produced by Neovim's default experience is probably not a job for Harpoon.

Please let me know if I misunderstood your question, it's certainly possible I did.

kimabrandt-flx commented 2 months ago

@dabstractor

I think you're right, that there's not much to do, about the swap-error!

I think with never versions of Neovim (e.g. v0.10.0), this issue will go away!? See https://github.com/neovim/neovim/pull/25336!

Having said that; I was referring to, when I try this change with Neovim v0.9.5.

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1702233742

After choosing one of: [O]pen, (E)dit, (R)ecover, (Q)uit, (A)bort, I get the E5108: Error executing lua, together with the E325: ATTENTION.

Also, choosing (Q)uit or (A)bort works as expected here: The file is not loaded.

I was just wondering, if there was a way to suppress the error in Lua!? But, never mind! I'm already using v0.10.0 for daily activities ;)

Edit: I guess, wrapping vim.api.nvim_command() with a pcall works!? But, will take some more changes!?

dabstractor commented 2 months ago

I like your PR a lot better, thank you.