Skip to content

Commit

Permalink
fix: buffer options order (#300)
Browse files Browse the repository at this point in the history
## 📃 Summary

The default and/or user defined buffer/window options override the
scratchPad options, which makes the buffer uneditable when it's enabled

closes #295
  • Loading branch information
shortcuts authored Feb 4, 2024
1 parent 3005aec commit fdbd8bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lua/no-neck-pain/wins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,13 @@ function W.createSideBuffers(skipIntegrations)
vim.api.nvim_buf_set_name(0, "no-neck-pain-" .. side)
end

S.setSideID(S, id, side)
initSideOptions(id, side)

if _G.NoNeckPain.config.buffers[side].scratchPad.enabled then
W.initScratchPad(side)
S.setScratchpad(S, true)
end

initSideOptions(id, side)

S.setSideID(S, id, side)
end

local sideID = S.getSideID(S, side)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_scratchpad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ T["scratchPad"]["forwards the given filetype to the scratchpad"] = function()
enabled = true
},
bo = {
filetype = "nnp"
filetype = "md"
},
},
})]])
Expand All @@ -219,10 +219,10 @@ T["scratchPad"]["forwards the given filetype to the scratchpad"] = function()
eq(helpers.winsInTab(child), { 1001, 1000, 1002 })

child.lua("vim.fn.win_gotoid(1001)")
eq(child.lua_get("vim.api.nvim_buf_get_option(0, 'filetype')"), "nnp")
eq(child.lua_get("vim.api.nvim_buf_get_option(0, 'filetype')"), "markdown")

child.lua("vim.fn.win_gotoid(1002)")
eq(child.lua_get("vim.api.nvim_buf_get_option(0, 'filetype')"), "nnp")
eq(child.lua_get("vim.api.nvim_buf_get_option(0, 'filetype')"), "markdown")
end

return T

0 comments on commit fdbd8bf

Please sign in to comment.