Skip to content

Commit 87b3a43

Browse files
committed
fix: remove interceptor complexity, letting default handlers take care of the operation
1 parent e865ceb commit 87b3a43

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

src/extensionsIntegrated/TabBar/main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,6 @@ define(function (require, exports, module) {
512512

513513
// open tab on mousedown event
514514
$(document).on("mousedown", ".phoenix-tab-bar .tab", function (event) {
515-
// to prevent right-clicks from making the tab active
516-
if (event.button === 2) { return; }
517-
518515
if ($(event.target).hasClass("fa-times") || $(event.target).closest(".tab-close").length) {
519516
return;
520517
}

src/extensionsIntegrated/TabBar/more-options.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ define(function (require, exports, module) {
6565
}
6666
}
6767

68-
// **Close**
69-
// closes the right-clicked tab
70-
function handleCloseTab() {
71-
_executeWithFileContext(Commands.FILE_CLOSE, { paneId: _currentTabContext.paneId });
72-
}
73-
7468
// **Close All Tabs**
7569
// closes all tabs in the pane where the tab was right-clicked
7670
function handleCloseAllTabs() {
@@ -120,27 +114,6 @@ define(function (require, exports, module) {
120114
}
121115
}
122116

123-
// **Rename**
124-
// renames the right-clicked tab's file
125-
function handleFileRename() {
126-
CommandManager.execute(Commands.SHOW_SIDEBAR);
127-
_executeWithFileContext(Commands.FILE_RENAME);
128-
}
129-
130-
// **Delete**
131-
// deletes the right-clicked tab's file
132-
function handleFileDelete() {
133-
_executeWithFileContext(Commands.FILE_DELETE);
134-
}
135-
136-
// **Show in File Tree**
137-
// shows the right-clicked tab's file in the file tree
138-
function handleShowInFileTree() {
139-
CommandManager.execute(Commands.SHOW_SIDEBAR);
140-
_executeWithFileContext(Commands.NAVIGATE_SHOW_IN_FILE_TREE);
141-
}
142-
143-
144117
/**
145118
* this function is called from Tabbar/main.js when a tab is right clicked
146119
* it is responsible to show the context menu and also set the currentTabContext
@@ -183,30 +156,6 @@ define(function (require, exports, module) {
183156
menu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE);
184157
menu.addMenuDivider();
185158
menu.addMenuItem(Commands.FILE_REOPEN_CLOSED);
186-
187-
// intercept clicks on existing commands
188-
// this is done so that we can inject the right-clicked tab's context
189-
menu.on("beforeContextMenuOpen", function () {
190-
const $menu = $(`#${menu.id} > ul`);
191-
if (!$menu.length) { return; }
192-
193-
// for other commands, we have built-in context as those are our custom functions
194-
const interceptors = [
195-
[Commands.FILE_CLOSE, handleCloseTab],
196-
[Commands.FILE_RENAME, handleFileRename],
197-
[Commands.FILE_DELETE, handleFileDelete],
198-
[Commands.NAVIGATE_SHOW_IN_FILE_TREE, handleShowInFileTree]
199-
];
200-
201-
interceptors.forEach(([commandId, handler]) => {
202-
$menu.find(`a[data-command="${commandId}"]`).off("click").on("click", function (e) {
203-
e.stopPropagation();
204-
e.preventDefault();
205-
handler();
206-
menu.close();
207-
});
208-
});
209-
});
210159
}
211160

212161
module.exports = {

0 commit comments

Comments
 (0)