@@ -35,11 +35,15 @@ define(function (require, exports, module) {
3535 // these are Tab bar specific commands for the context menu
3636 // not added in the Commands.js as Tab bar is not a core module but an extension
3737 // read init function
38- const TABBAR_CLOSE_TABS_LEFT = "tabbar.closeTabsLeft" ;
39- const TABBAR_CLOSE_TABS_RIGHT = "tabbar.closeTabsRight" ;
4038 const TABBAR_CLOSE_SAVED_TABS = "tabbar.closeSavedTabs" ;
4139 const TABBAR_CLOSE_ALL = "tabbar.closeAllTabs" ;
4240
41+ // command IDs from working files - we reuse it here with different labels
42+ // Close Others Above = Close Tabs to the Left
43+ // Close Others Below = Close Tabs to the Right
44+ const FILE_CLOSE_ABOVE = "file.close_above" ;
45+ const FILE_CLOSE_BELOW = "file.close_below" ;
46+
4347 // stores the context of the right-clicked tab (which file, which pane)
4448 // this is set inside the showMoreOptionsContextMenu. read that func for more details
4549 let _currentTabContext = { filePath : null , paneId : null } ;
@@ -58,6 +62,12 @@ define(function (require, exports, module) {
5862
5963 const pinCommand = CommandManager . get ( Commands . FILE_PIN ) ;
6064 pinCommand . setName ( isPinned ? Strings . CMD_FILE_UNPIN : Strings . CMD_FILE_PIN ) ;
65+
66+ // update Close Above/Below labels for TabBar context (Left/Right instead of Above/Below)
67+ const closeAboveCmd = CommandManager . get ( FILE_CLOSE_ABOVE ) ;
68+ const closeBelowCmd = CommandManager . get ( FILE_CLOSE_BELOW ) ;
69+ closeAboveCmd . setName ( Strings . CLOSE_TABS_TO_THE_LEFT ) ;
70+ closeBelowCmd . setName ( Strings . CLOSE_TABS_TO_THE_RIGHT ) ;
6171 }
6272
6373 // gets the working set (list of open files) for the given pane
@@ -103,34 +113,6 @@ define(function (require, exports, module) {
103113 }
104114 }
105115
106- // **Close Tabs to the Left**
107- // closes all tabs to the left of the right-clicked tab
108- function handleCloseTabsToTheLeft ( ) {
109- const workingSet = _getWorkingSet ( _currentTabContext . paneId ) ;
110- if ( ! workingSet ) { return ; }
111-
112- // find where the right-clicked tab is in the list
113- const currentIndex = workingSet . findIndex ( entry => entry . path === _currentTabContext . filePath ) ;
114- if ( currentIndex > 0 ) {
115- // slice from start to currentIndex (not including currentIndex)
116- _closeFiles ( workingSet . slice ( 0 , currentIndex ) , _currentTabContext . paneId ) ;
117- }
118- }
119-
120- // **Close Tabs to the Right**
121- // closes all tabs to the right of the right-clicked tab
122- function handleCloseTabsToTheRight ( ) {
123- const workingSet = _getWorkingSet ( _currentTabContext . paneId ) ;
124- if ( ! workingSet ) { return ; }
125-
126- // find where the right-clicked tab is in the list
127- const currentIndex = workingSet . findIndex ( entry => entry . path === _currentTabContext . filePath ) ;
128- if ( currentIndex !== - 1 && currentIndex < workingSet . length - 1 ) {
129- // slice from currentIndex+1 to end
130- _closeFiles ( workingSet . slice ( currentIndex + 1 ) , _currentTabContext . paneId ) ;
131- }
132- }
133-
134116 /**
135117 * this function is called from Tabbar/main.js when a tab is right clicked
136118 * it is responsible to show the context menu and also set the currentTabContext
@@ -155,16 +137,13 @@ define(function (require, exports, module) {
155137 */
156138 function init ( ) {
157139 // these are the tab bar specific commands
158- CommandManager . register ( Strings . CLOSE_TABS_TO_THE_LEFT , TABBAR_CLOSE_TABS_LEFT , handleCloseTabsToTheLeft ) ;
159- CommandManager . register ( Strings . CLOSE_TABS_TO_THE_RIGHT , TABBAR_CLOSE_TABS_RIGHT , handleCloseTabsToTheRight ) ;
160140 CommandManager . register ( Strings . CLOSE_SAVED_TABS , TABBAR_CLOSE_SAVED_TABS , handleCloseSavedTabs ) ;
161141 CommandManager . register ( Strings . CLOSE_ALL_TABS , TABBAR_CLOSE_ALL , handleCloseAllTabs ) ;
162142
163- // these commands already exist for working files, just reusing them
164143 const menu = Menus . registerContextMenu ( "tabbar-context-menu" ) ;
165144 menu . addMenuItem ( Commands . FILE_CLOSE ) ;
166- menu . addMenuItem ( TABBAR_CLOSE_TABS_LEFT ) ;
167- menu . addMenuItem ( TABBAR_CLOSE_TABS_RIGHT ) ;
145+ menu . addMenuItem ( FILE_CLOSE_ABOVE ) ; // updated label will be : "Close Tabs to the Left"
146+ menu . addMenuItem ( FILE_CLOSE_BELOW ) ; // updated label will be : "Close Tabs to the Right"
168147 menu . addMenuItem ( TABBAR_CLOSE_SAVED_TABS ) ;
169148 menu . addMenuItem ( TABBAR_CLOSE_ALL ) ;
170149 menu . addMenuDivider ( ) ;
0 commit comments