Skip to content

Commit e5557d5

Browse files
committed
feat: add rename and delete option in tab
1 parent cc8f122 commit e5557d5

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/extensionsIntegrated/TabBar/more-options.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ define(function (require, exports, module) {
4040
Strings.CLOSE_ALL_TABS,
4141
Strings.CLOSE_UNMODIFIED_TABS,
4242
"---",
43+
Strings.RENAME_TAB_FILE,
44+
Strings.DELETE_TAB_FILE,
45+
"---",
4346
Strings.REOPEN_CLOSED_FILE
4447
];
4548

@@ -219,6 +222,43 @@ define(function (require, exports, module) {
219222
}
220223

221224

225+
/**
226+
* "RENAME FILE"
227+
* This function handles the renaming of the file that was right-clicked
228+
*
229+
* @param {String} filePath - path of the file to rename
230+
*/
231+
function handleFileRename(filePath) {
232+
if (filePath) {
233+
// First ensure the sidebar is visible so users can see the rename action
234+
CommandManager.execute(Commands.SHOW_SIDEBAR);
235+
236+
// Get the file object using FileSystem
237+
const fileObj = FileSystem.getFileForPath(filePath);
238+
239+
// Execute the rename command with the file object
240+
CommandManager.execute(Commands.FILE_RENAME, {file: fileObj});
241+
}
242+
}
243+
244+
245+
/**
246+
* "DELETE FILE"
247+
* This function handles the deletion of the file that was right-clicked
248+
*
249+
* @param {String} filePath - path of the file to delete
250+
*/
251+
function handleFileDelete(filePath) {
252+
if (filePath) {
253+
// Get the file object using FileSystem
254+
const fileObj = FileSystem.getFileForPath(filePath);
255+
256+
// Execute the delete command with the file object
257+
CommandManager.execute(Commands.FILE_DELETE, {file: fileObj});
258+
}
259+
}
260+
261+
222262
/**
223263
* This function is called when a tab is right-clicked
224264
* This will show the more options context menu
@@ -279,6 +319,12 @@ define(function (require, exports, module) {
279319
case Strings.CLOSE_UNMODIFIED_TABS:
280320
handleCloseUnmodifiedTabs(paneId);
281321
break;
322+
case Strings.RENAME_TAB_FILE:
323+
handleFileRename(filePath);
324+
break;
325+
case Strings.DELETE_TAB_FILE:
326+
handleFileDelete(filePath);
327+
break;
282328
case Strings.REOPEN_CLOSED_FILE:
283329
reopenClosedFile();
284330
break;

src/nls/root/strings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ define({
433433
"CLOSE_ALL_TABS": "Close All Tabs",
434434
"CLOSE_UNMODIFIED_TABS": "Close Unmodified Tabs",
435435
"REOPEN_CLOSED_FILE": "Reopen Closed File",
436+
"RENAME_TAB_FILE": "Rename File",
437+
"DELETE_TAB_FILE": "Delete File",
436438

437439
// CodeInspection: errors/warnings
438440
"ERRORS_NO_FILE": "No File Open",

0 commit comments

Comments
 (0)