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

[bug]: need to do killAllBuffersOnDisable three times #420

Open
1 task done
ilan-schemoul opened this issue Nov 29, 2024 · 4 comments
Open
1 task done

[bug]: need to do killAllBuffersOnDisable three times #420

ilan-schemoul opened this issue Nov 29, 2024 · 4 comments
Assignees
Labels
need investigation When an issue lack context/is not straight forward to solve not confirmed when a bug is reported but not yet reproduced

Comments

@ilan-schemoul
Copy link

Description

killAllBuffersOnDisable = true
I have two windows. I do z one time nothing happens. Second time right pane is closed. Third time I enter finally in NoNeckPain mode (window centered).

https://asciinema.org/a/PjILOtkDcZofOs1rp4RxLdG9g

Neovim version

0.9.x

Steps to reproduce

Lazy config

return {
  "shortcuts/no-neck-pain.nvim",
  init = function()
    vim.api.nvim_create_autocmd("FileType", {
      pattern = "no-neck-pain",
      callback = function()
        vim.b.focus_disable = true
        vim.b.nonumber = 1;
      end
    })
  end,
  opts = {
    killAllBuffersOnDisable = true,
  },
  keys = {
    { "<leader>z", "<Cmd>NoNeckPain<CR>" }
  },
}

My repo

Relevant log output

:messages
W325: Ignoring swapfile from Nvim process 1587548
[no-neck-pain.nvim@public_api_toggle] >> debouncer triggered
[no-neck-pain.nvim@public_api_toggle] calling enable for tab 1
[no-neck-pain.nvim@set_tab] registered new tab 1
[no-neck-pain.nvim@public_api_toggle] computed columns: 0 - 2
[no-neck-pain.nvim@public_api_toggle] init called on tab 1 for current window 1000
[no-neck-pain.nvim@get_side_width:left] 0/180 after integrations - 2 columns remaining
[no-neck-pain.nvim@get_side_width:left] 200/180 - no space left to create side
[no-neck-pain.nvim@get_side_width:right] 0/180 after integrations - 2 columns remaining
[no-neck-pain.nvim@get_side_width:right] 200/180 - no space left to create side
[no-neck-pain.nvim@public_api_toggle] computed columns: 2 - 2
[no-neck-pain.nvim@public_api_toggle] >> debouncer triggered
[no-neck-pain.nvim@public_api_toggle] calling disable for tab 1
[no-neck-pain.nvim@public_api_toggle] refreshing tabs...
[no-neck-pain.nvim@public_api_toggle] no more active tabs left, reinitializing state
[no-neck-pain.nvim@public_api_toggle] >> debouncer triggered
[no-neck-pain.nvim@public_api_toggle] calling enable for tab 1
[no-neck-pain.nvim@set_tab] registered new tab 1
[no-neck-pain.nvim@public_api_toggle] computed columns: 0 - 1
[no-neck-pain.nvim@public_api_toggle] init called on tab 1 for current window 1000
[no-neck-pain.nvim@get_side_width:left] 0/180 after integrations - 1 columns remaining
[no-neck-pain.nvim@get_side_width:left] 100/180 after splits - final 40
[no-neck-pain.nvim@get_side_width:right] 0/180 after integrations - 1 columns remaining
[no-neck-pain.nvim@get_side_width:right] 100/180 after splits - final 40
[[email protected]] skipping color initialization for side left
[[email protected]] skipping color initialization for side right
[no-neck-pain.nvim@left] resizing 1011 with padding 40
[no-neck-pain.nvim@right] resizing 1012 with padding 40
[no-neck-pain.nvim@public_api_toggle] rerouting focus of 1012 to

Self-service

  • I'd be willing to fix this bug myself.
@ilan-schemoul ilan-schemoul added the bug Something isn't working label Nov 29, 2024
@ilan-schemoul
Copy link
Author

Also is there a way to restore closed windows after leaving NoNeckPain mode

@ilan-schemoul
Copy link
Author

I think the problem is the code vim.cmd("only") is called in main.disable instead of main.enable.

However once I do that fix I have another problem: the layout is not saved. To save the window layout the very simple solution is to open a new tab and close a new tab.

However this plugin seems to not take this approach of using tabnew/tabclose.

So I just added my own solution to my code. It is actually much simpler to roll out my own solution than trying to make this plugin or any other plugin fit my workflow.

Here is the commit for those interested.

@shortcuts
Copy link
Owner

Hey @ilan-schemoul thanks for using the plugin :D

I'm not totally sure to understand what is the issue here, I tried locally and disabling the plugin with killAllBuffersOnDisable properly kills every focused windows.

Looking at your issue description, it seems like you'd expect that enabling the plugin only keeps the focused window, right?

@shortcuts shortcuts added need investigation When an issue lack context/is not straight forward to solve not confirmed when a bug is reported but not yet reproduced and removed bug Something isn't working labels Nov 30, 2024
@shortcuts shortcuts self-assigned this Nov 30, 2024
@ilan-schemoul
Copy link
Author

Oh gosh I'm so stupid.
killAllBuffersOnDisable obviously kills buffer when I disable.
I expected it to kill other windows on enable. I do not know how I missed that, it's embarassing haha.

What I wanted is I have two windows
window A | window B

When I NoNeckPain on Window A it first kills window B. Then center window A.
When I disable NoNeckPain it stops center window A and then it shows again
window A | window B

As I said I created my own solutions ilan-schemoul/nvim-config@642ebf1 when I use tabnew and tabclose without this plugin because it does what I want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need investigation When an issue lack context/is not straight forward to solve not confirmed when a bug is reported but not yet reproduced
Projects
None yet
Development

No branches or pull requests

2 participants