File tree Expand file tree Collapse file tree 4 files changed +25
-0
lines changed
Expand file tree Collapse file tree 4 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ Default mappings:
2222| ` <C-W>, ` | Go to tab on the right. |
2323| ` <C-W>. ` | Move the current tab one position to the left. |
2424| ` <C-W>/ ` | Move the current tab one position to the right. |
25+ | ` <C-W>c ` | Check if there are any taberian tabs present and ask user to confirm closing the window. |
2526| ` <A-1> ` | Go to tab 1. |
2627| ` <A-2> ` | Go to tab 2. |
2728| ` <A-3> ` | Go to tab 3. |
@@ -50,6 +51,7 @@ map <silent> <C-W>m <Cmd>TaberianGotoLeftTab<CR>
5051map <silent> <C-W>, <Cmd>TaberianGotoRightTab<CR>
5152map <silent> <C-W>. <Cmd>TaberianMoveCurrentTabLeft<CR>
5253map <silent> <C-W>/ <Cmd>TaberianMoveCurrentTabRight<CR>
54+ map <silent> <C-W>c <Cmd>TaberianConfirmWindowClose<CR>
5355map <silent> <A-1> <Cmd>TaberianGoToTabNr 0<CR>
5456map <silent> <A-2> <Cmd>TaberianGoToTabNr 1<CR>
5557map <silent> <A-3> <Cmd>TaberianGoToTabNr 2<CR>
Original file line number Diff line number Diff line change @@ -198,3 +198,17 @@ function! taberian#render_all_windows()
198198 call win_execute (winid, ' call taberian#update_current_window()' )
199199 endfor
200200endfunction
201+
202+ function ! taberian#confirm_window_close ()
203+ if len (w: taberian .tabs ) > 1
204+ echo ' This window has ' . len (w: taberian .tabs ) . ' tabs open: '
205+ echo w: taberian .tabs - >deepcopy ()- >map ({_, tab - > fnamemodify (bufname (tab .bufnr ), ' :t' )})- >string ()
206+ echo ' Are you sure you wish to close the window (yN):'
207+ let choice = nr2char (getchar ())
208+ redraw
209+ if choice !=# ' y'
210+ return
211+ endif
212+ endif
213+ close
214+ endfunction
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ mappings:
4747 *taberian-move-tab-right*
4848<C-W>/ Move the current tab one position to the right.
4949
50+ *taberian-confirm-window-close*
51+ <C-W>c Check if there are any taberian tabs present and ask user
52+ to confirm closing the window.
53+
5054<A-1> Go to tab 1.
5155<A-2> Go to tab 2.
5256<A-3> Go to tab 3.
@@ -72,6 +76,7 @@ using this example:
7276 map <silent> <C-W>, <Cmd>TaberianGotoRightTab<CR>
7377 map <silent> <C-W>. <Cmd>TaberianMoveCurrentTabLeft<CR>
7478 map <silent> <C-W>/ <Cmd>TaberianMoveCurrentTabRight<CR>
79+ map <silent> <C-W>c <Cmd>TaberianConfirmWindowClose<CR>
7580 map <silent> <A-1> <Cmd>TaberianGoToTabNr 0<CR>
7681 map <silent> <A-2> <Cmd>TaberianGoToTabNr 1<CR>
7782 map <silent> <A-3> <Cmd>TaberianGoToTabNr 2<CR>
@@ -100,6 +105,8 @@ COMMANDS *taberian-commands*
100105
101106:TaberianMoveCurrentTabRight See |taberian-move-tab-right|.
102107
108+ :TaberianConfirmWindowClose See |taberian-confirm-window-close|.
109+
103110:TaberianGoToTabNr N Go to tab with index N. Taberian tab indices
104111 are zero-based, use 0 to go to the first tab.
105112
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ command! -nargs=0 TaberianGotoLeftTab :call taberian#goto_tab_offset(-1)
1515command ! -nargs =0 TaberianGotoRightTab :call taberian#goto_tab_offset (+ 1 )
1616command ! -nargs =0 TaberianMoveCurrentTabLeft :call taberian#move_current_tab_offset (-1 )
1717command ! -nargs =0 TaberianMoveCurrentTabRight :call taberian#move_current_tab_offset (+ 1 )
18+ command ! -nargs =0 TaberianConfirmWindowClose :call taberian#confirm_window_close ()
1819command ! -nargs =1 TaberianGoToTabNr :call taberian#goto_tab_nr (<q-args> )
1920command ! -nargs =0 TaberianGoToPreviousTab :call taberian#goto_previous_tab ()
2021
@@ -25,6 +26,7 @@ if !exists('g:taberian_no_default_mappings') || !g:taberian_no_default_mappings
2526 map <silent> <C-W> , <Cmd> TaberianGotoRightTab<CR>
2627 map <silent> <C-W> . <Cmd> TaberianMoveCurrentTabLeft<CR>
2728 map <silent> <C-W> / <Cmd> TaberianMoveCurrentTabRight<CR>
29+ map <silent> <C-W> c <Cmd> TaberianConfirmWindowClose<CR>
2830 map <silent> <A-1> <Cmd> TaberianGoToTabNr 0<CR>
2931 map <silent> <A-2> <Cmd> TaberianGoToTabNr 1<CR>
3032 map <silent> <A-3> <Cmd> TaberianGoToTabNr 2<CR>
You can’t perform that action at this time.
0 commit comments