From 189e21ae50efe14d8446db11aee6b50f8022d99f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 May 2023 08:13:33 +0800 Subject: 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 --- src/nvim/tag.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index ff16a10d8e..81bca67cf7 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2901,21 +2901,10 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) buf_T *const existing_buf = buflist_findname_exp(fname); if (existing_buf != NULL) { - const win_T *wp = NULL; - - if (swb_flags & SWB_USEOPEN) { - wp = buf_jump_open_win(existing_buf); - } - - // If 'switchbuf' contains "usetab": jump to first window in any tab - // page containing "existing_buf" if one exists - if (wp == NULL && (swb_flags & SWB_USETAB)) { - wp = buf_jump_open_tab(existing_buf); - } - - // We've switched to the buffer, the usual loading of the file must - // be skipped. - if (wp != NULL) { + // If 'switchbuf' is set jump to the window containing "buf". + if (swbuf_goto_win_with_buf(existing_buf) != NULL) { + // We've switched to the buffer, the usual loading of the file + // must be skipped. getfile_result = GETFILE_SAME_FILE; } } -- cgit