Skip to content

Commit fb05eaa

Browse files
authored
Merge pull request #89 from francescarpi/develop
release: v2025-03-26
2 parents 078826e + 43c1678 commit fb05eaa

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ Take a look at the default shortcuts for navigating between buffers, changing th
139139
close_others = "<buffonleader>cd",
140140
reopen_recent_closed_buffer = "<buffonleader>t",
141141
show_help = "<buffonleader>h",
142-
previous_page = "<s-o>",
143-
next_page = "<s-p>",
142+
previous_page = "<buffonleader>z",
143+
next_page = "<buffonleader>x",
144144
move_to_previous_page = "<buffonleader>a",
145145
move_to_next_page = "<buffonleader>s",
146146
},

lua/buffon/config.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ local default = {
3636
close_others = "<buffonleader>cd",
3737
reopen_recent_closed_buffer = "<buffonleader>t",
3838
show_help = "<buffonleader>h",
39-
previous_page = "<s-o>",
40-
next_page = "<s-p>",
39+
previous_page = "<buffonleader>z",
40+
next_page = "<buffonleader>x",
4141
move_to_previous_page = "<buffonleader>a",
4242
move_to_next_page = "<buffonleader>s",
4343
},

lua/buffon/maincontroller.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,18 @@ function MainController:action_open_or_activate_buffer(buf)
383383
log.debug("open", buf.filename, "with id", buf.id)
384384

385385
if buf.id then
386-
pcall(vim.api.nvim_set_current_buf, buf.id)
386+
-- If the buffer is in a different window than the active one, we will activate that window.
387+
-- This is useful for split windows.
388+
-- For example: We have the screen split with buffer A on the left and buffer B on the right.
389+
-- If we are on the left (A) and want to switch to buffer B, instead of opening B on the left,
390+
-- the right window will be activated.
391+
local wins_id = vim.fn.win_findbuf(buf.id)
392+
if wins_id and wins_id[1] then
393+
log.debug("buffer is in another window", wins_id[1])
394+
vim.api.nvim_set_current_win(wins_id[1])
395+
else
396+
pcall(vim.api.nvim_set_current_buf, buf.id)
397+
end
387398
else
388399
vim.api.nvim_command("edit " .. buf.name)
389400
buf.id = vim.api.nvim_get_current_buf()

tests/config_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ describe("config", function()
3434
close_others = "<buffonleader>cd",
3535
reopen_recent_closed_buffer = "<buffonleader>t",
3636
show_help = "<buffonleader>h",
37-
previous_page = "<s-o>",
38-
next_page = "<s-p>",
37+
previous_page = "<buffonleader>z",
38+
next_page = "<buffonleader>x",
3939
move_to_previous_page = "<buffonleader>a",
4040
move_to_next_page = "<buffonleader>s",
4141
},

0 commit comments

Comments
 (0)