shortcuts / no-neck-pain.nvim

☕ Dead simple yet super extensible plugin to center the currently focused buffer to the middle of the screen.
MIT License
459 stars 12 forks source link

prevent nvim quitting unsaved buffers - follow up of #348 #363

Closed shortcuts closed 1 month ago

shortcuts commented 1 month ago
          > > I would like to  have :q never close NNP, which I think is a sane default. Basically this issue: #348

Thanks for your suggestion @vinoff, I can't make it a default as it changes how nvim behaves natively but I'd be happily make it an opt-in option!

Do you expect NNP to re-create a window in that case? If there's none to redirect the focus too

I think you are misunderstanding the issue @shortcuts. This is how other plugins work, for example neo-tree. I just tested it.

With Neo-tree:

With NNP:

What it should do instead is give a warning, just like Neo-tree does. It should never close the NNP window since it is not focused. If one wants to close the NNP window, one has many ways to do that. Just running :NNP is one, or just creating a keybind. Or just moving focus to the NNP window and doing :q. Now, closing a window with :q while another window is being focused is just bad UX, imo.

Originally posted by @vinoff in https://github.com/shortcuts/no-neck-pain.nvim/issues/361#issuecomment-2126511600

shortcuts commented 1 month ago

Referencing your comment here @vinoff as I now properly understood the issue, I believe I can fix that before the next major.

shortcuts commented 1 month ago

@vinoff would you mind giving a shot to https://github.com/shortcuts/no-neck-pain.nvim/pull/364 and highlight if something still bothers you?

vinoff commented 1 month ago

@shortcuts, yes! But there is something weird going on, try to reproduce on your end please:

This last point is weird.. It seems like NNP width decreases.. A small amount, but still. Does this also happen on your end?

It only happens on the first :q though. If I keep doing :q :q :q :q, the size remains constant. But the first :q does change size. I wonder if there is some other plugin that is causing it.

vinoff commented 1 month ago

There is a nasty bug @shortcuts:

EDIT: :qa! works though. But :q! should work also.

shortcuts commented 1 month ago

There is a nasty bug @shortcuts:

  • Open nvim (I mean nvim itself, not a file. Just do "nvim", without a file path)
  • Edit the window (just add some random text, whatever).
  • Do not save.
  • Do :q!
  • It doesn't close. It should close, since you are doing "!".

EDIT: :qa! works though. But :q! should work also.

Thanks for trying the fix!! this one should've been fixed, for the other resize issue, I'm not able to consistently reproduce it but it might not directly be related to this fix, as I leverage the same solution as for the init of the plugin, I'll continue to investigate

shortcuts commented 1 month ago

feat released here https://github.com/shortcuts/no-neck-pain.nvim/releases/tag/v1.14.0

vinoff commented 1 month ago

There is a nasty bug @shortcuts:

  • Open nvim (I mean nvim itself, not a file. Just do "nvim", without a file path)
  • Edit the window (just add some random text, whatever).
  • Do not save.
  • Do :q!
  • It doesn't close. It should close, since you are doing "!".

EDIT: :qa! works though. But :q! should work also.

Thanks for trying the fix!! this one should've been fixed, for the other resize issue, I'm not able to consistently reproduce it but it might not directly be related to this fix, as I leverage the same solution as for the init of the plugin, I'll continue to investigate

I confirm that the q! is fixed. The resize still happens to me. Just to be sure, it also happens to you, right? Or is it something on my side?

If it helps, there seems to appear a white dot in the upper right corner of NNP when the resize happens.

shortcuts commented 1 month ago

I confirm that the q! is fixed. The resize still happens to me. Just to be sure, it also happens to you, right? Or is it something on my side?

If it helps, there seems to appear a white dot in the upper right corner of NNP when the resize happens.

Yes I managed to repro on a big screen but not on my laptop, I guess when I compute the remaining width, there is a .5 offset that sometimes gets rounded or floored, which I'll try to fix also but separately