Mercurial > vim
comparison src/window.c @ 32429:bfc23ba1bba5 v9.0.1546
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Commit: https://github.com/vim/vim/commit/54be5fb382d2bf25fd1b17ddab8b21f599019b81
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Fri May 12 17:49:13 2023 +0100
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Problem: Some commands for opening a file don't use 'switchbuf'.
Solution: Use 'switchbuf' for more commands. (Yegappan Lakshmanan,
closes #12383, closes #12381)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 12 May 2023 19:00:04 +0200 |
parents | c114eebb5268 |
children | 48b95cef8fa2 |
comparison
equal
deleted
inserted
replaced
32428:46c8cee129fc | 32429:bfc23ba1bba5 |
---|---|
578 win_T *oldwin = curwin; | 578 win_T *oldwin = curwin; |
579 #ifdef FEAT_GUI | 579 #ifdef FEAT_GUI |
580 need_mouse_correct = TRUE; | 580 need_mouse_correct = TRUE; |
581 #endif | 581 #endif |
582 setpcmark(); | 582 setpcmark(); |
583 if (win_split(0, 0) == OK) | 583 |
584 // If 'switchbuf' is set to 'useopen' or 'usetab' and the | |
585 // file is already opened in a window, then jump to it. | |
586 wp = NULL; | |
587 if ((swb_flags & (SWB_USEOPEN | SWB_USETAB)) | |
588 && cmdmod.cmod_tab == 0) | |
589 { | |
590 buf_T *existing_buf = buflist_findname_exp(ptr); | |
591 | |
592 if (existing_buf != NULL) | |
593 { | |
594 if (swb_flags & SWB_USEOPEN) | |
595 wp = buf_jump_open_win(existing_buf); | |
596 | |
597 // If 'switchbuf' contains "usetab": jump to first | |
598 // window in any tab page containing "existing_buf" | |
599 // if one exists. | |
600 if (wp == NULL && (swb_flags & SWB_USETAB)) | |
601 wp = buf_jump_open_tab(existing_buf); | |
602 } | |
603 } | |
604 | |
605 if (wp == NULL && win_split(0, 0) == OK) | |
584 { | 606 { |
585 RESET_BINDING(curwin); | 607 RESET_BINDING(curwin); |
586 if (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, | 608 if (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, |
587 ECMD_HIDE, NULL) == FAIL) | 609 ECMD_HIDE, NULL) == FAIL) |
588 { | 610 { |
589 // Failed to open the file, close the window | 611 // Failed to open the file, close the window |
590 // opened for it. | 612 // opened for it. |
591 win_close(curwin, FALSE); | 613 win_close(curwin, FALSE); |
592 goto_tabpage_win(oldtab, oldwin); | 614 goto_tabpage_win(oldtab, oldwin); |
593 } | 615 } |
594 else if (nchar == 'F' && lnum >= 0) | 616 else |
595 { | 617 wp = curwin; |
596 curwin->w_cursor.lnum = lnum; | 618 } |
597 check_cursor_lnum(); | 619 |
598 beginline(BL_SOL | BL_FIX); | 620 if (wp != NULL && nchar == 'F' && lnum >= 0) |
599 } | 621 { |
622 curwin->w_cursor.lnum = lnum; | |
623 check_cursor_lnum(); | |
624 beginline(BL_SOL | BL_FIX); | |
600 } | 625 } |
601 vim_free(ptr); | 626 vim_free(ptr); |
602 } | 627 } |
603 break; | 628 break; |
604 | 629 |