summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-05-14 17:24:22 +0100
committerBram Moolenaar <Bram@vim.org>2023-05-14 17:24:22 +0100
commite42c27d9e8a18e3786f13f17663914cdd0f63f9e (patch)
treec0dc0141813003df4a767dfd90863ff6870be3c3 /src/buffer.c
parentb6a19594b29a7d4f33a1f4324a0579df61f48d06 (diff)
patch 9.0.1554: code for handling 'switchbuf' is repeatedv9.0.1554
Problem: Code for handling 'switchbuf' is repeated. Solution: Add a function to handle 'switchbuf'. (Yegappan Lakshmanan, closes #12397)
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 60b7c80971..dc279ffb19 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1570,14 +1570,10 @@ do_buffer_ext(
*/
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;
}
@@ -2492,15 +2488,8 @@ buflist_getfile(
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