aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-05-15 08:13:33 +0800
committerGitHub <noreply@github.com>2023-05-15 08:13:33 +0800
commit189e21ae50efe14d8446db11aee6b50f8022d99f (patch)
tree7fa33b913722d280d39f0e0948ad356fe67a8664 /src/nvim/buffer.c
parent4a0005aee9b51e1b91794623ad06b9a8a2343ba9 (diff)
downloadrneovim-189e21ae50efe14d8446db11aee6b50f8022d99f.tar.gz
rneovim-189e21ae50efe14d8446db11aee6b50f8022d99f.tar.bz2
rneovim-189e21ae50efe14d8446db11aee6b50f8022d99f.zip
vim-patch:9.0.1554: code for handling 'switchbuf' is repeated (#23632)
Problem: Code for handling 'switchbuf' is repeated. Solution: Add a function to handle 'switchbuf'. (Yegappan Lakshmanan, closes vim/vim#12397) https://github.com/vim/vim/commit/e42c27d9e8a18e3786f13f17663914cdd0f63f9e Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 8d730733d0..b2edbf4053 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1459,16 +1459,11 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
// make "buf" the current buffer
if (action == DOBUF_SPLIT) { // split window first
- // If 'switchbuf' contains "useopen": jump to first window containing
- // "buf" if one exists
- if ((swb_flags & SWB_USEOPEN) && buf_jump_open_win(buf)) {
- return OK;
- }
- // If 'switchbuf' contains "usetab": jump to first window in any tab
- // page containing "buf" if one exists
- if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf)) {
+ // If 'switchbuf' is set jump to the window containing "buf".
+ if (swbuf_goto_win_with_buf(buf) != NULL) {
return OK;
}
+
if (win_split(0, 0) == FAIL) {
return FAIL;
}
@@ -2072,17 +2067,8 @@ int buflist_getfile(int n, linenr_T lnum, int options, int forceit)
}
if (options & GETF_SWITCH) {
- // If 'switchbuf' contains "useopen": jump to first window containing
- // "buf" if one exists
- if (swb_flags & SWB_USEOPEN) {
- wp = buf_jump_open_win(buf);
- }
-
- // If 'switchbuf' contains "usetab": jump to first window in any tab
- // page containing "buf" if one exists
- if (wp == NULL && (swb_flags & SWB_USETAB)) {
- wp = buf_jump_open_tab(buf);
- }
+ // If 'switchbuf' is set jump to the window containing "buf".
+ wp = swbuf_goto_win_with_buf(buf);
// If 'switchbuf' contains "split", "vsplit" or "newtab" and the
// current buffer isn't empty: open new tab or window