@@ -42,11 +42,11 @@ define(function (require, exports, module) {
4242 "---" ,
4343 Strings . RENAME_TAB_FILE ,
4444 Strings . DELETE_TAB_FILE ,
45+ Strings . SHOW_IN_FILE_TREE ,
4546 "---" ,
4647 Strings . REOPEN_CLOSED_FILE
4748 ] ;
4849
49-
5050 /**
5151 * "CLOSE TAB"
5252 * this function handles the closing of the tab that was right-clicked
@@ -60,14 +60,10 @@ define(function (require, exports, module) {
6060 const fileObj = FileSystem . getFileForPath ( filePath ) ;
6161
6262 // Execute close command with file object and pane ID
63- CommandManager . execute (
64- Commands . FILE_CLOSE ,
65- { file : fileObj , paneId : paneId }
66- ) ;
63+ CommandManager . execute ( Commands . FILE_CLOSE , { file : fileObj , paneId : paneId } ) ;
6764 }
6865 }
6966
70-
7167 /**
7268 * "CLOSE ALL TABS"
7369 * This will close all tabs in the specified pane
@@ -88,14 +84,10 @@ define(function (require, exports, module) {
8884 // close each file in the pane, start from the rightmost [to avoid index shifts]
8985 for ( let i = workingSet . length - 1 ; i >= 0 ; i -- ) {
9086 const fileObj = FileSystem . getFileForPath ( workingSet [ i ] . path ) ;
91- CommandManager . execute (
92- Commands . FILE_CLOSE ,
93- { file : fileObj , paneId : paneId }
94- ) ;
87+ CommandManager . execute ( Commands . FILE_CLOSE , { file : fileObj , paneId : paneId } ) ;
9588 }
9689 }
9790
98-
9991 /**
10092 * "CLOSE UNMODIFIED TABS"
10193 * This will close all tabs that are not modified in the specified pane
@@ -114,19 +106,15 @@ define(function (require, exports, module) {
114106 }
115107
116108 // get all those entries that are not dirty
117- const unmodifiedEntries = workingSet . filter ( entry => ! entry . isDirty ) ;
109+ const unmodifiedEntries = workingSet . filter ( ( entry ) => ! entry . isDirty ) ;
118110
119111 // close each unmodified file in the pane
120112 for ( let i = unmodifiedEntries . length - 1 ; i >= 0 ; i -- ) {
121113 const fileObj = FileSystem . getFileForPath ( unmodifiedEntries [ i ] . path ) ;
122- CommandManager . execute (
123- Commands . FILE_CLOSE ,
124- { file : fileObj , paneId : paneId }
125- ) ;
114+ CommandManager . execute ( Commands . FILE_CLOSE , { file : fileObj , paneId : paneId } ) ;
126115 }
127116 }
128117
129-
130118 /**
131119 * "CLOSE TABS TO THE LEFT"
132120 * This function is responsible for closing all tabs to the left of the right-clicked tab
@@ -146,24 +134,21 @@ define(function (require, exports, module) {
146134 }
147135
148136 // find the index of the current file in the working set
149- const currentIndex = workingSet . findIndex ( entry => entry . path === filePath ) ;
137+ const currentIndex = workingSet . findIndex ( ( entry ) => entry . path === filePath ) ;
150138
151- if ( currentIndex > 0 ) { // we only proceed if there are tabs to the left
139+ if ( currentIndex > 0 ) {
140+ // we only proceed if there are tabs to the left
152141 // get all files to the left of the current file
153142 const filesToClose = workingSet . slice ( 0 , currentIndex ) ;
154143
155144 // Close each file, starting from the rightmost [to avoid index shifts]
156145 for ( let i = filesToClose . length - 1 ; i >= 0 ; i -- ) {
157146 const fileObj = FileSystem . getFileForPath ( filesToClose [ i ] . path ) ;
158- CommandManager . execute (
159- Commands . FILE_CLOSE ,
160- { file : fileObj , paneId : paneId }
161- ) ;
147+ CommandManager . execute ( Commands . FILE_CLOSE , { file : fileObj , paneId : paneId } ) ;
162148 }
163149 }
164150 }
165151
166-
167152 /**
168153 * "CLOSE TABS TO THE RIGHT"
169154 * This function is responsible for closing all tabs to the right of the right-clicked tab
@@ -183,23 +168,19 @@ define(function (require, exports, module) {
183168 }
184169
185170 // get the index of the current file in the working set
186- const currentIndex = workingSet . findIndex ( entry => entry . path === filePath ) ;
171+ const currentIndex = workingSet . findIndex ( ( entry ) => entry . path === filePath ) ;
187172 // only proceed if there are tabs to the right
188173 if ( currentIndex !== - 1 && currentIndex < workingSet . length - 1 ) {
189174 // get all files to the right of the current file
190175 const filesToClose = workingSet . slice ( currentIndex + 1 ) ;
191176
192177 for ( let i = filesToClose . length - 1 ; i >= 0 ; i -- ) {
193178 const fileObj = FileSystem . getFileForPath ( filesToClose [ i ] . path ) ;
194- CommandManager . execute (
195- Commands . FILE_CLOSE ,
196- { file : fileObj , paneId : paneId }
197- ) ;
179+ CommandManager . execute ( Commands . FILE_CLOSE , { file : fileObj , paneId : paneId } ) ;
198180 }
199181 }
200182 }
201183
202-
203184 /**
204185 * "REOPEN CLOSED FILE"
205186 * This just calls the reopen closed file command. everthing else is handled there
@@ -209,7 +190,6 @@ define(function (require, exports, module) {
209190 CommandManager . execute ( Commands . FILE_REOPEN_CLOSED ) ;
210191 }
211192
212-
213193 /**
214194 * "RENAME FILE"
215195 * This function handles the renaming of the file that was right-clicked
@@ -225,11 +205,10 @@ define(function (require, exports, module) {
225205 const fileObj = FileSystem . getFileForPath ( filePath ) ;
226206
227207 // Execute the rename command with the file object
228- CommandManager . execute ( Commands . FILE_RENAME , { file : fileObj } ) ;
208+ CommandManager . execute ( Commands . FILE_RENAME , { file : fileObj } ) ;
229209 }
230210 }
231211
232-
233212 /**
234213 * "DELETE FILE"
235214 * This function handles the deletion of the file that was right-clicked
@@ -242,10 +221,28 @@ define(function (require, exports, module) {
242221 const fileObj = FileSystem . getFileForPath ( filePath ) ;
243222
244223 // Execute the delete command with the file object
245- CommandManager . execute ( Commands . FILE_DELETE , { file : fileObj } ) ;
224+ CommandManager . execute ( Commands . FILE_DELETE , { file : fileObj } ) ;
246225 }
247226 }
248227
228+ /**
229+ * "SHOW IN FILE TREE"
230+ * This function handles showing the file in the file tree
231+ *
232+ * @param {String } filePath - path of the file to show in file tree
233+ */
234+ function handleShowInFileTree ( filePath ) {
235+ if ( filePath ) {
236+ // First ensure the sidebar is visible so users can see the file in the tree
237+ CommandManager . execute ( Commands . SHOW_SIDEBAR ) ;
238+
239+ // Get the file object using FileSystem
240+ const fileObj = FileSystem . getFileForPath ( filePath ) ;
241+
242+ // Execute the show in tree command with the file object
243+ CommandManager . execute ( Commands . NAVIGATE_SHOW_IN_FILE_TREE , { file : fileObj } ) ;
244+ }
245+ }
249246
250247 /**
251248 * This function is called when a tab is right-clicked
@@ -318,6 +315,9 @@ define(function (require, exports, module) {
318315 case Strings . DELETE_TAB_FILE :
319316 handleFileDelete ( filePath ) ;
320317 break ;
318+ case Strings . SHOW_IN_FILE_TREE :
319+ handleShowInFileTree ( filePath ) ;
320+ break ;
321321 case Strings . REOPEN_CLOSED_FILE :
322322 reopenClosedFile ( ) ;
323323 break ;
0 commit comments