Skip to content

Commit c0611ef

Browse files
committed
fix: set winfixbuf
This prevents accessing nvim-dap-view's bufs in undesirable scenarios (e.g., when moving through the jumplist) We still can't get rid of "that crazy autocmd" because there's no way to handle switchbuf's newtab, which creates the tab with the original (nvim-dap-view's) filetype (therefore updating `state.winnr`)
1 parent b0b3861 commit c0611ef

File tree

8 files changed

+15
-0
lines changed

8 files changed

+15
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
docs/node_modules
2+
docs/dist

lua/dap-view/options/winbar/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ local custom_action_wrapper = function(view)
3333
M.set_action_keymaps(custom_bufnrs[view])
3434

3535
api.nvim_win_call(state.winnr, function()
36+
vim.wo[state.winnr][0].winfixbuf = false
3637
api.nvim_set_current_buf(custom_bufnrs[view])
38+
vim.wo[state.winnr][0].winfixbuf = true
3739
end)
3840
end
3941

lua/dap-view/repl/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ local M = {}
66
M.show = function()
77
-- Jump to dap-view's window to make the experience seamless
88
local cmd = "lua vim.api.nvim_set_current_win(" .. state.winnr .. ")"
9+
vim.wo[state.winnr][0].winfixbuf = false
910
local repl_buf, _ = require("dap").repl.open(nil, cmd)
11+
vim.wo[state.winnr][0].winfixbuf = true
1012

1113
-- The REPL is a new buffer, so we need to set the winbar keymaps again
1214
winbar.set_action_keymaps(repl_buf)

lua/dap-view/term/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ M.show = function()
1818
assert(state.current_session_id, "has active session")
1919

2020
api.nvim_win_call(state.winnr, function()
21+
vim.wo[state.winnr][0].winfixbuf = false
2122
api.nvim_set_current_buf(state.term_bufnrs[state.current_session_id])
23+
vim.wo[state.winnr][0].winfixbuf = true
2224
end)
2325

2426
require("dap-view.term.options").set_win_options(state.winnr)
@@ -99,7 +101,9 @@ M.switch_term_buf = function()
99101
---@cast winnr integer
100102

101103
api.nvim_win_call(winnr, function()
104+
vim.wo[winnr][0].winfixbuf = false
102105
api.nvim_set_current_buf(state.term_bufnrs[state.current_session_id])
106+
vim.wo[winnr][0].winfixbuf = true
103107

104108
if is_console_active then
105109
winbar.refresh_winbar("console")

lua/dap-view/term/options.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ M.set_win_options = function(winnr)
1010
win.winfixheight = true
1111
win.statuscolumn = ""
1212
win.foldcolumn = "0"
13+
win.winfixbuf = true
1314
end
1415

1516
return M

lua/dap-view/views/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ M.switch_to_view = function(view)
4141
)
4242
then
4343
api.nvim_win_call(state.winnr, function()
44+
vim.wo[state.winnr][0].winfixbuf = false
4445
api.nvim_set_current_buf(state.bufnr)
46+
vim.wo[state.winnr][0].winfixbuf = true
4547
end)
4648
end
4749

lua/dap-view/views/keymaps/help.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ M.show_help = function()
7373
vim.wo[help_win][0].cursorline = true
7474
vim.wo[help_win][0].cursorlineopt = "line"
7575

76+
vim.wo[help_win][0].winfixbuf = true
77+
7678
api.nvim_create_autocmd("WinClosed", {
7779
buffer = help_buf,
7880
callback = function()

lua/dap-view/views/options.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ M.set_options = function()
1313
win.cursorline = true
1414
win.statuscolumn = ""
1515
win.foldcolumn = "0"
16+
win.winfixbuf = true
1617

1718
local buf = vim.bo[state.bufnr]
1819
buf.buftype = "nofile"

0 commit comments

Comments
 (0)