File tree Expand file tree Collapse file tree 5 files changed +34
-2
lines changed
Expand file tree Collapse file tree 5 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 3333- (NSInteger )addTabAtIndex : (NSInteger )index ;
3434
3535- (void )closeTab : (MMTab *)tab force : (BOOL )force layoutImmediately : (BOOL )layoutImmediately ;
36+ - (void )closeAllTabs ;
3637
3738// / Batch update all the tabs using tab tags as unique IDs. Tab line will handle
3839// / creating / removing tabs as necessary, and moving tabs to their new
Original file line number Diff line number Diff line change @@ -315,6 +315,18 @@ - (void)closeTab:(MMTab *)tab force:(BOOL)force layoutImmediately:(BOOL)layoutIm
315315 }
316316}
317317
318+ - (void )closeAllTabs
319+ {
320+ _selectedTabIndex = -1 ;
321+ _draggedTab = nil ;
322+ _initialDraggedTabIndex = _finalDraggedTabIndex = NSNotFound ;
323+ for (MMTab *tab in _tabs) {
324+ [tab removeFromSuperview ];
325+ }
326+ [_tabs removeAllObjects ];
327+ [self fixupLayoutWithAnimation: NO ];
328+ }
329+
318330- (void )updateTabsByTags : (NSInteger *)tags len : (NSUInteger )len delayTabResize : (BOOL )delayTabResize
319331{
320332 BOOL needUpdate = NO ;
@@ -564,7 +576,13 @@ - (void)fixupTabZOrder
564576
565577- (void )fixupLayoutWithAnimation : (BOOL )shouldAnimate delayResize : (BOOL )delayResize
566578{
567- if (_tabs.count == 0 ) return ;
579+ if (_tabs.count == 0 ) {
580+ NSRect frame = _tabsContainer.frame ;
581+ frame.size .width = 0 ;
582+ _tabsContainer.frame = frame;
583+ [self updateTabScrollButtonsEnabledState ];
584+ return ;
585+ }
568586
569587 if (delayResize) {
570588 // The pending delayed resize is trigged by mouse exit, but if we are
Original file line number Diff line number Diff line change 4444
4545- (MMTabline *)tabline ;
4646- (IBAction )addNewTab : (id )sender ;
47+ - (void )showTabline : (BOOL )on ;
4748- (void )updateTabsWithData : (NSData *)data ;
4849- (void )refreshTabProperties ;
4950
Original file line number Diff line number Diff line change @@ -251,9 +251,21 @@ - (void)setDesiredRows:(int)r columns:(int)c
251251
252252- (IBAction )addNewTab : (id )sender
253253{
254+ // Callback from the "Create a new tab button". We override this so we can
255+ // send a message to Vim first and let it handle it before replying back.
254256 [vimController sendMessage: AddNewTabMsgID data: nil ];
255257}
256258
259+ - (void )showTabline : (BOOL )on
260+ {
261+ [tabline setHidden: !on];
262+ if (!on) {
263+ // When the tab is not shown we don't get tab updates from Vim. We just
264+ // close all of them as otherwise we will be holding onto stale states.
265+ [tabline closeAllTabs ];
266+ }
267+ }
268+
257269// / Callback from Vim to update the tabline with new tab data
258270- (void )updateTabsWithData : (NSData *)data
259271{
Original file line number Diff line number Diff line change @@ -868,7 +868,7 @@ - (void)processInputQueueDidFinish
868868
869869- (void )showTabline : (BOOL )on
870870{
871- [[ vimView tabline ] setHidden: ! on];
871+ [vimView showTabline: on];
872872 [self updateTablineSeparator ];
873873 shouldMaximizeWindow = YES ;
874874}
You can’t perform that action at this time.
0 commit comments